Skip to content

Commit 48c5948

Browse files
committed
Add failing test
1 parent 71a461e commit 48c5948

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/system/Database/Migrations/MigrationRunnerTest.php

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

457+
/**
458+
* @runInSeparateProcess
459+
* @preserveGlobalState disabled
460+
*/
461+
public function testMigrationUsesSameConnectionAsMigrationRunner(): void
462+
{
463+
$config = ['database' => WRITEPATH . 'runner.sqlite', 'DBDriver' => 'SQLite3', 'DBDebug' => true];
464+
465+
if (is_file($config['database'])) {
466+
unlink($config['database']);
467+
}
468+
469+
$database = Database::connect($config, false);
470+
471+
$runner = new MigrationRunner(config(Migrations::class), $database);
472+
$runner->clearCliMessages();
473+
$runner->clearHistory();
474+
$runner->setNamespace('Tests\Support\MigrationTestMigrations');
475+
$runner->latest();
476+
477+
$tables = $database->listTables();
478+
$this->assertCount(2, $tables);
479+
$this->assertSame('migrations', $tables[0]);
480+
$this->assertSame('foo', $tables[1]);
481+
}
482+
457483
protected function resetTables(): void
458484
{
459485
$forge = Config::forge();

0 commit comments

Comments
 (0)