@@ -33,6 +33,12 @@ final class MigrationRunnerTest extends CIUnitTestCase
3333 use DatabaseTestTrait;
3434
3535 protected $ refresh = true ;
36+
37+ // Do not migrate automatically, because we test migrations.
38+ protected $ migrate = false ;
39+
40+ // Use specific migration files for this test case.
41+ protected $ namespace = 'Tests\Support\MigrationTestMigrations ' ;
3642 protected $ root ;
3743 protected $ start ;
3844 protected $ config ;
@@ -62,6 +68,8 @@ protected function tearDown(): void
6268 {
6369 parent ::tearDown ();
6470
71+ // To delete data with `$this->regressDatabase()`, set it true.
72+ $ this ->migrate = true ;
6573 $ this ->regressDatabase ();
6674 }
6775
@@ -342,10 +350,11 @@ public function testLatestTriggersEvent()
342350 {
343351 $ runner = new MigrationRunner ($ this ->config );
344352 $ runner ->setSilent (false )
345- ->setNamespace ('Tests\Support\MigrationTestMigrations ' )
346- ->clearHistory ();
353+ ->setNamespace ('Tests\Support\MigrationTestMigrations ' );
347354
348355 $ result = null ;
356+
357+ Events::removeAllListeners ();
349358 Events::on ('migrate ' , static function ($ arg ) use (&$ result ) {
350359 $ result = $ arg ;
351360 });
@@ -360,10 +369,10 @@ public function testRegressTriggersEvent()
360369 {
361370 $ runner = new MigrationRunner ($ this ->config );
362371 $ runner ->setSilent (false )
363- ->setNamespace ('Tests\Support\MigrationTestMigrations ' )
364- ->clearHistory ();
372+ ->setNamespace ('Tests\Support\MigrationTestMigrations ' );
365373
366374 $ result = null ;
375+ Events::removeAllListeners ();
367376 Events::on ('migrate ' , static function ($ arg ) use (&$ result ) {
368377 $ result = $ arg ;
369378 });
0 commit comments