Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions tests/TestCase/Migration/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -163,6 +164,9 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface
}
$adapter->disconnect();

// Recreate the migration state table.
$adapter->createSchemaTable();

return $adapter;
}

Expand Down Expand Up @@ -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',
]);
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);
Expand All @@ -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');
}
Expand All @@ -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);
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Loading