Skip to content

Commit 8d22082

Browse files
committed
Add failing test
1 parent 71a461e commit 8d22082

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,34 @@ public function testGetBatchVersions(): void
454454
$this->assertSame('2018-01-24-102302', $runner->getBatchEnd(1));
455455
}
456456

457-
protected function resetTables(): void
457+
/**
458+
* @runInSeparateProcess
459+
* @preserveGlobalState disabled
460+
*/
461+
public function testMigrationUsesSameConnectionAsMigrationRunner(): void
458462
{
459-
$forge = Config::forge();
463+
$config = ['database' => WRITEPATH . 'runner.sqlite', 'DBDriver' => 'SQLite3', 'DBDebug' => true];
460464

461-
foreach (db_connect()->listTables() as $table) {
465+
$database = Database::connect($config, false);
466+
$this->resetTables($database);
467+
468+
$runner = new MigrationRunner(config(Migrations::class), $database);
469+
$runner->clearCliMessages();
470+
$runner->clearHistory();
471+
$runner->setNamespace('Tests\Support\MigrationTestMigrations');
472+
$runner->latest();
473+
474+
$tables = $database->listTables();
475+
$this->assertCount(2, $tables);
476+
$this->assertSame('migrations', $tables[0]);
477+
$this->assertSame('foo', $tables[1]);
478+
}
479+
480+
protected function resetTables($db = null): void
481+
{
482+
$forge = Database::forge($db);
483+
484+
foreach (db_connect($db)->listTables() as $table) {
462485
$table = str_replace('db_', '', $table);
463486
$forge->dropTable($table, true);
464487
}

0 commit comments

Comments
 (0)