In your TestCase.php
(or in any other test if you want use memory database only in that test) you can override setUp()
method
public function setUp()
{
parent::setUp();
$this->app['config']->set('database.default', 'testing');
$this->app['config']->set('database.connections.testing', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
]);
}
You can use Illuminate\Foundation\Testing\DatabaseMigrations
in test class body as well. In this case, php artisan migrate:refresh
will be called before each test
<?php
use Illuminate\Foundation\Testing\DatabaseMigrations;
class ExampleTest extends TestCase
{
use DatabaseMigrations;
// ...
// test cases
// ...
}