diff --git a/tests/TestCase/Migration/ManagerTest.php b/tests/TestCase/Migration/ManagerTest.php index 26035d24..b7cb7ed4 100644 --- a/tests/TestCase/Migration/ManagerTest.php +++ b/tests/TestCase/Migration/ManagerTest.php @@ -146,6 +146,7 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface 'pass' => $connectionConfig['password'], 'host' => $connectionConfig['host'], 'name' => $connectionConfig['database'], + 'database' => $connectionConfig['database'], ]; $configArray['environment'] = $adapterConfig; @@ -163,6 +164,9 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface } $adapter->disconnect(); + // Recreate the migration state table. + $adapter->createSchemaTable(); + return $adapter; } @@ -2460,7 +2464,9 @@ public function testGettingIo(): void public function testReversibleMigrationsWorkAsExpected(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); + if ($this->getDriverType() === 'sqlite') { + $this->markTestSkipped('Test is not compatible with sqlite'); + } $adapter = $this->prepareEnvironment([ 'migrations' => ROOT . '/config/Reversiblemigrations', ]); @@ -2504,7 +2510,6 @@ public function testReversibleMigrationsWorkAsExpected(): void public function testReversibleMigrationWithIndexConflict(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); if ($this->getDriverType() !== 'mysql') { $this->markTestSkipped('Test requires mysql connection'); } @@ -2521,6 +2526,7 @@ public function testReversibleMigrationWithIndexConflict(): void $adapter->dropDatabase($dbName); $adapter->createDatabase($dbName); $adapter->disconnect(); + $adapter->createSchemaTable(); // migrate to the latest version $this->manager->setConfig($config); @@ -2545,7 +2551,6 @@ public function testReversibleMigrationWithIndexConflict(): void public function testReversibleMigrationWithFKConflictOnTableDrop(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); if ($this->getDriverType() !== 'mysql') { $this->markTestSkipped('Test requires mysql'); } @@ -2562,6 +2567,7 @@ public function testReversibleMigrationWithFKConflictOnTableDrop(): void $adapter->dropDatabase($dbName); $adapter->createDatabase($dbName); $adapter->disconnect(); + $adapter->createSchemaTable(); // migrate to the latest version $this->manager->setConfig($config); @@ -2591,7 +2597,6 @@ public function testReversibleMigrationWithFKConflictOnTableDrop(): void public function testBreakpointsTogglingOperateAsExpected(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); if ($this->getDriverType() !== 'mysql') { $this->markTestSkipped('Test requires mysql'); } @@ -2606,6 +2611,7 @@ public function testBreakpointsTogglingOperateAsExpected(): void $adapter->dropDatabase($dbName); $adapter->createDatabase($dbName); $adapter->disconnect(); + $adapter->createSchemaTable(); // migrate to the latest version $this->manager->setConfig($config); @@ -2761,7 +2767,6 @@ public function testBreakpointsTogglingOperateAsExpected(): void public function testBreakpointWithInvalidVersion(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); if ($this->getDriverType() !== 'mysql') { $this->markTestSkipped('test requires mysql'); } @@ -2776,17 +2781,16 @@ public function testBreakpointWithInvalidVersion(): void $adapter->dropDatabase($dbName); $adapter->createDatabase($dbName); $adapter->disconnect(); + $adapter->createSchemaTable(); // migrate to the latest version $this->manager->setConfig($config); $this->manager->migrate(); - $this->manager->getOutput()->setDecorated(false); // set breakpoint on most recent migration $this->manager->toggleBreakpoint(999); - rewind($this->manager->getOutput()->getStream()); - $output = stream_get_contents($this->manager->getOutput()->getStream()); + $output = implode("\n", $this->out->messages()); $this->assertStringContainsString('is not a valid version', $output); } @@ -2916,7 +2920,6 @@ public function testInvalidVersionBreakpoint(): void public function testMigrationWillNotBeExecuted(): void { - $this->markTestIncomplete('Need to finish updating adapters to use Connection'); if ($this->getDriverType() !== 'mysql') { $this->markTestSkipped('Test requires mysql'); } diff --git a/tests/test_app/config/Reversiblemigrations/20190928220334_add_column_index_fk.php b/tests/test_app/config/Reversiblemigrations/20190928220334_add_column_index_fk.php index f35525ed..bb1338d4 100644 --- a/tests/test_app/config/Reversiblemigrations/20190928220334_add_column_index_fk.php +++ b/tests/test_app/config/Reversiblemigrations/20190928220334_add_column_index_fk.php @@ -44,18 +44,11 @@ public function change() 'unique' => false, ]); - if ($this->getAdapter()->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'sqlite') { - $table->addForeignKey('user_id', 'users', 'id', [ - 'update' => ForeignKey::NO_ACTION, - 'delete' => ForeignKey::NO_ACTION, - ]); - } else { - $table->addForeignKey('user_id', 'users', 'id', [ - 'constraint' => 'statuses_users_id', - 'update' => ForeignKey::NO_ACTION, - 'delete' => ForeignKey::NO_ACTION, - ]); - } + $table->addForeignKey('user_id', 'users', 'id', [ + 'constraint' => 'statuses_users_id', + 'update' => ForeignKey::NO_ACTION, + 'delete' => ForeignKey::NO_ACTION, + ]); $table->update(); }