title: Error when testing Laravel controller with mockery: Call to a member function fetchMock() on a non-object
body: <p>I receive the following error when making a PHPUnit test with Mockery (dev-master) of the controller in Laravel 4.2 :</p>
  
  <p><strong>Fatal error: Call to a member function fetchMock() on a non-object in \laravel\vendor\mockery\mockery\library\Mockery.php on line 129</strong></p>
  
  <p>The controller and test are as follows:</p>
  
  <pre><code>class UserControllerTest extends TestCase {
    public function __construct() {
      $this-&gt;mock = Mockery::mock('Eloquent', 'User');
    }
    function tearDown() {
      Mockery::close();
    }
    public function testIndex() {
      $this-&gt;mock
        -&gt;shouldReceive('all')
        -&gt;once()
        -&gt;andReturn('foo');
      $this-&gt;app-&gt;instance('User', $this-&gt;mock);
      $response = $this-&gt;action('GET', 'UserController@index');
      //other stuff
    }
  }
  
  class UserController extends \BaseController {
    protected $user;
    public function __construct(User $user) {
      $this-&gt;user = $user;
    }
    public function index() {
      $users = $this-&gt;user-&gt;all();
      return View::make('users.index', ['users' =&gt; $users]);
    }
    //other stuff
  }
  </code></pre>
  
  <p>This test works ok without Mockery (i.e. without executing <code>$this-&gt;app-&gt;instance('User', $this-&gt;mock);</code> )</p>
  
  <p>The error is raised inside <strong>fetchMock</strong> function, when executing
  <code>return self::$_container-&gt;fetchMock($name);</code></p>
  
  <p>Here are the values visible in debugger inside fetchMock when it fails:</p>
  
  <p><img src="https://i.stack.imgur.com/p4eDc.jpg" alt="enter image description here"></p>
  
  <p>What is causing this error?</p>