mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
test: fix MigrationRunnerTest
This commit is contained in:
parent
000c115bca
commit
1ad510b61d
@ -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;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user