Does this affect multiple/all of your tests? Are you sure that the tests are working? Have you run them on a different database before?
In memory database leads to The table is empty.
Decided to try out the in memory DB for testing on a new project. Using Homestead and the latest Laravel. Can't seem to get things working no matter what I try. Been through all of the threads on all the sites and nothing seems to be working.
1) Tests\Feature\UserTest::a_guest_should_be_able_to_register
Failed asserting that a row in the table [users] matches the attributes {
"email": "[email protected]",
"name": "TestUser"
}.
The table is empty.
Here is my stuff:
//config/database.php
'connections' => [
'testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
// phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
</php>
</phpunit>
I have been clearing my config cache constantly.
TestCase.php uses the RefreshDatabase trait and I have even done this in a number of places down the testing chain to confirm its the right database being used during the tests:
$connection = config('database.default');
$driver = config("database.connections.{$connection}.database");
dd($driver);
Anyone have any other tricks they know of to get this working?
Stupid question have you tried to use /registerinstead of just register?
Try adding $this.->withoutExceptionHandling(); in the beginning of the test.
And what is the content of the oops page?
Please or to participate in this conversation.