You may want to try using it this way:
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
This always works for me.
I'm not able to run tests through SQLite,
Running: phpunit -c phpunit.xml
I did manage to change:
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
<exclude>
<file>./app/routes/web.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="DB_CONNECTION" value="testing_sqlite"/>
<env name="DB_TYPE" value="testing_sqlite"/>
<ini name="display_errors" value="On" />
<ini name="display_startup_errors" value="On" />
</php>
</phpunit>
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'testing_sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:', // storage_path().'/testing.sqlite',
'prefix' => '',
],
]
The most shady thing is that I had to apply
protected $connectionsToTransact = ['mysql', 'sqlite'];
in TestCase class
because it was not wrapping transaction over , so I figured out that somewhere mysql connection is defined (??!) and it should be added to remove
Return from PHPUnit
PHPUnit 4.8.31 by Sebastian Bergmann and contributors.
.EE
Time: 528 ms, Memory: 17.75MB
There were 2 errors:
1) GenericListingManagerTest::it_allows_to_add_items
InvalidArgumentException: Database [mysql] not configured.
and that's the case because I do not use "mysql" driver/connection in phpunit configs:
Please or to participate in this conversation.