title: ModelFactory: Error: Call to a member function connection() on null
body: <p>While trying to populate database using ModelFactory I am coming across this bit of error, I have been looking up since the last six hours, can not seem to fix it.</p>
  
  <p>My Test runs this:</p>
  
  <pre><code>$books = factory('App\Book', 2)-&gt;create();
  </code></pre>
  
  <p>and the error message is this:</p>
  
  <pre><code>There was 1 error:
  
  1) Tests\App\Http\Controllers\BooksControllerTest::testIndexReturnsCollection
  Error: Call to a member function connection() on null
  
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\Model.php:1234
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\Model.php:1200
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\Model.php:1030
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\Model.php:945
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\Model.php:983
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\FactoryBuilder.php:203
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\support\Collection.php:407
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\FactoryBuilder.php:207
  D:\Code\Server\htdocs\rlfp.localhost.com\vendor\illuminate\database\Eloquent\FactoryBuilder.php:185
  D:\Code\Server\htdocs\rlfp.localhost.com\tests\app\Http\Controllers\BooksControllerTest.php:35
  </code></pre>
  
  <p>On my bootstrap/app.php I have on line 26 and 28, like so:</p>
  
  <pre><code>$app-&gt;withFacades();
  
  $app-&gt;withEloquent();
  </code></pre>
  
  <p>While my phpunit.xml is like so:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;phpunit backupGlobals="false"
           backupStaticAttributes="false"
           bootstrap="bootstrap/app.php"
           colors="true"
           convertErrorsToExceptions="true"
           convertNoticesToExceptions="true"
           convertWarningsToExceptions="true"
           processIsolation="false"
           stopOnFailure="false"&gt;
      &lt;testsuites&gt;
          &lt;testsuite name="Application Test Suite"&gt;
              &lt;directory suffix="Test.php"&gt;./tests&lt;/directory&gt;
          &lt;/testsuite&gt;
      &lt;/testsuites&gt;
      &lt;filter&gt;
          &lt;whitelist processUncoveredFilesFromWhitelist="true"&gt;
              &lt;directory suffix=".php"&gt;./app&lt;/directory&gt;
          &lt;/whitelist&gt;
      &lt;/filter&gt;
      &lt;php&gt;
          &lt;env name="APP_ENV" value="testing"/&gt;
          &lt;env name="CACHE_DRIVER" value="array"/&gt;
          &lt;env name="QUEUE_DRIVER" value="sync"/&gt;
          &lt;env name="DB_DATABASE" value="rlp_rlfpsfactory"/&gt;
      &lt;/php&gt;
  &lt;/phpunit&gt;
  </code></pre>
  
  <p>Do I need to put anything else in the php part of phpunit xml file?</p>