Skip to content

Commit 33c8484

Browse files
authored
Merge pull request #899 from cakephp/restore-incomplete-integration-tests
Fix incomplete tests
2 parents 0b4f9c3 + 4ec6afe commit 33c8484

2 files changed

Lines changed: 17 additions & 21 deletions

File tree

tests/TestCase/Migration/ManagerTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface
146146
'pass' => $connectionConfig['password'],
147147
'host' => $connectionConfig['host'],
148148
'name' => $connectionConfig['database'],
149+
'database' => $connectionConfig['database'],
149150
];
150151

151152
$configArray['environment'] = $adapterConfig;
@@ -163,6 +164,9 @@ protected function prepareEnvironment(array $paths = []): AdapterInterface
163164
}
164165
$adapter->disconnect();
165166

167+
// Recreate the migration state table.
168+
$adapter->createSchemaTable();
169+
166170
return $adapter;
167171
}
168172

@@ -2460,7 +2464,9 @@ public function testGettingIo(): void
24602464

24612465
public function testReversibleMigrationsWorkAsExpected(): void
24622466
{
2463-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
2467+
if ($this->getDriverType() === 'sqlite') {
2468+
$this->markTestSkipped('Test is not compatible with sqlite');
2469+
}
24642470
$adapter = $this->prepareEnvironment([
24652471
'migrations' => ROOT . '/config/Reversiblemigrations',
24662472
]);
@@ -2504,7 +2510,6 @@ public function testReversibleMigrationsWorkAsExpected(): void
25042510

25052511
public function testReversibleMigrationWithIndexConflict(): void
25062512
{
2507-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
25082513
if ($this->getDriverType() !== 'mysql') {
25092514
$this->markTestSkipped('Test requires mysql connection');
25102515
}
@@ -2521,6 +2526,7 @@ public function testReversibleMigrationWithIndexConflict(): void
25212526
$adapter->dropDatabase($dbName);
25222527
$adapter->createDatabase($dbName);
25232528
$adapter->disconnect();
2529+
$adapter->createSchemaTable();
25242530

25252531
// migrate to the latest version
25262532
$this->manager->setConfig($config);
@@ -2545,7 +2551,6 @@ public function testReversibleMigrationWithIndexConflict(): void
25452551

25462552
public function testReversibleMigrationWithFKConflictOnTableDrop(): void
25472553
{
2548-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
25492554
if ($this->getDriverType() !== 'mysql') {
25502555
$this->markTestSkipped('Test requires mysql');
25512556
}
@@ -2562,6 +2567,7 @@ public function testReversibleMigrationWithFKConflictOnTableDrop(): void
25622567
$adapter->dropDatabase($dbName);
25632568
$adapter->createDatabase($dbName);
25642569
$adapter->disconnect();
2570+
$adapter->createSchemaTable();
25652571

25662572
// migrate to the latest version
25672573
$this->manager->setConfig($config);
@@ -2591,7 +2597,6 @@ public function testReversibleMigrationWithFKConflictOnTableDrop(): void
25912597

25922598
public function testBreakpointsTogglingOperateAsExpected(): void
25932599
{
2594-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
25952600
if ($this->getDriverType() !== 'mysql') {
25962601
$this->markTestSkipped('Test requires mysql');
25972602
}
@@ -2606,6 +2611,7 @@ public function testBreakpointsTogglingOperateAsExpected(): void
26062611
$adapter->dropDatabase($dbName);
26072612
$adapter->createDatabase($dbName);
26082613
$adapter->disconnect();
2614+
$adapter->createSchemaTable();
26092615

26102616
// migrate to the latest version
26112617
$this->manager->setConfig($config);
@@ -2761,7 +2767,6 @@ public function testBreakpointsTogglingOperateAsExpected(): void
27612767

27622768
public function testBreakpointWithInvalidVersion(): void
27632769
{
2764-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
27652770
if ($this->getDriverType() !== 'mysql') {
27662771
$this->markTestSkipped('test requires mysql');
27672772
}
@@ -2776,17 +2781,16 @@ public function testBreakpointWithInvalidVersion(): void
27762781
$adapter->dropDatabase($dbName);
27772782
$adapter->createDatabase($dbName);
27782783
$adapter->disconnect();
2784+
$adapter->createSchemaTable();
27792785

27802786
// migrate to the latest version
27812787
$this->manager->setConfig($config);
27822788
$this->manager->migrate();
2783-
$this->manager->getOutput()->setDecorated(false);
27842789

27852790
// set breakpoint on most recent migration
27862791
$this->manager->toggleBreakpoint(999);
27872792

2788-
rewind($this->manager->getOutput()->getStream());
2789-
$output = stream_get_contents($this->manager->getOutput()->getStream());
2793+
$output = implode("\n", $this->out->messages());
27902794

27912795
$this->assertStringContainsString('is not a valid version', $output);
27922796
}
@@ -2916,7 +2920,6 @@ public function testInvalidVersionBreakpoint(): void
29162920

29172921
public function testMigrationWillNotBeExecuted(): void
29182922
{
2919-
$this->markTestIncomplete('Need to finish updating adapters to use Connection');
29202923
if ($this->getDriverType() !== 'mysql') {
29212924
$this->markTestSkipped('Test requires mysql');
29222925
}

tests/test_app/config/Reversiblemigrations/20190928220334_add_column_index_fk.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,11 @@ public function change()
4444
'unique' => false,
4545
]);
4646

47-
if ($this->getAdapter()->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'sqlite') {
48-
$table->addForeignKey('user_id', 'users', 'id', [
49-
'update' => ForeignKey::NO_ACTION,
50-
'delete' => ForeignKey::NO_ACTION,
51-
]);
52-
} else {
53-
$table->addForeignKey('user_id', 'users', 'id', [
54-
'constraint' => 'statuses_users_id',
55-
'update' => ForeignKey::NO_ACTION,
56-
'delete' => ForeignKey::NO_ACTION,
57-
]);
58-
}
47+
$table->addForeignKey('user_id', 'users', 'id', [
48+
'constraint' => 'statuses_users_id',
49+
'update' => ForeignKey::NO_ACTION,
50+
'delete' => ForeignKey::NO_ACTION,
51+
]);
5952

6053
$table->update();
6154
}

0 commit comments

Comments
 (0)