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;
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 $start;
protected $config;
@ -62,6 +68,8 @@ final class MigrationRunnerTest extends CIUnitTestCase
{
parent::tearDown();
// To delete data with `$this->regressDatabase()`, set it true.
$this->migrate = true;
$this->regressDatabase();
}
@ -342,10 +350,11 @@ final class MigrationRunnerTest extends CIUnitTestCase
{
$runner = new MigrationRunner($this->config);
$runner->setSilent(false)
->setNamespace('Tests\Support\MigrationTestMigrations')
->clearHistory();
->setNamespace('Tests\Support\MigrationTestMigrations');
$result = null;
Events::removeAllListeners();
Events::on('migrate', static function ($arg) use (&$result) {
$result = $arg;
});
@ -360,10 +369,10 @@ final class MigrationRunnerTest extends CIUnitTestCase
{
$runner = new MigrationRunner($this->config);
$runner->setSilent(false)
->setNamespace('Tests\Support\MigrationTestMigrations')
->clearHistory();
->setNamespace('Tests\Support\MigrationTestMigrations');
$result = null;
Events::removeAllListeners();
Events::on('migrate', static function ($arg) use (&$result) {
$result = $arg;
});