test: fix MigrationRunnerTest

This commit is contained in:
kenjis 2022-04-12 11:24:26 +09:00
parent 000c115bca
commit 1ad510b61d
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -33,6 +33,12 @@ final class MigrationRunnerTest extends CIUnitTestCase
use DatabaseTestTrait; use DatabaseTestTrait;
protected $refresh = true; protected $refresh = true;
// Do not migrate automatically, because we test migrations.
protected $migrate = false;
// Use specific migration files for this test case.
protected $namespace = 'Tests\Support\MigrationTestMigrations';
protected $root; protected $root;
protected $start; protected $start;
protected $config; protected $config;
@ -62,6 +68,8 @@ final class MigrationRunnerTest extends CIUnitTestCase
{ {
parent::tearDown(); parent::tearDown();
// To delete data with `$this->regressDatabase()`, set it true.
$this->migrate = true;
$this->regressDatabase(); $this->regressDatabase();
} }
@ -342,10 +350,11 @@ final class MigrationRunnerTest extends CIUnitTestCase
{ {
$runner = new MigrationRunner($this->config); $runner = new MigrationRunner($this->config);
$runner->setSilent(false) $runner->setSilent(false)
->setNamespace('Tests\Support\MigrationTestMigrations') ->setNamespace('Tests\Support\MigrationTestMigrations');
->clearHistory();
$result = null; $result = null;
Events::removeAllListeners();
Events::on('migrate', static function ($arg) use (&$result) { Events::on('migrate', static function ($arg) use (&$result) {
$result = $arg; $result = $arg;
}); });
@ -360,10 +369,10 @@ final class MigrationRunnerTest extends CIUnitTestCase
{ {
$runner = new MigrationRunner($this->config); $runner = new MigrationRunner($this->config);
$runner->setSilent(false) $runner->setSilent(false)
->setNamespace('Tests\Support\MigrationTestMigrations') ->setNamespace('Tests\Support\MigrationTestMigrations');
->clearHistory();
$result = null; $result = null;
Events::removeAllListeners();
Events::on('migrate', static function ($arg) use (&$result) { Events::on('migrate', static function ($arg) use (&$result) {
$result = $arg; $result = $arg;
}); });