I'm running some migrations with SQLite, and my tests are using the RefreshDatabase trait. I also have seeders (registered in the DatabaseSeeder.php file) that should seed my tables. However, when I run my tests, the migrated databases are empty. That said, when I edit the RefreshDatabase trait to seed, it works fine:
protected function refreshTestDatabase()
{
if (! RefreshDatabaseState::$migrated) {
dump("Migrating DB in trait");
$this->artisan('migrate:fresh', $this->shouldDropViews() ? [
'--drop-views' => true,
] : []);
$this->artisan('db:seed');
$this->app[Kernel::class]->setArtisan(null);
RefreshDatabaseState::$migrated = true;
}
$this->beginDatabaseTransaction();
}
(Note the added $this->artisan('db:seed');)
I feel like there should be a way to run the Seeders without editing the core, but for the life of me I'm not sure why this is the thing that solves my problem. I'm running Laravel 5.6 on PHP 7.2 FWIW.