Skip to content

Commit

Permalink
Merge pull request #6819 from morozov/fix-test-switch-primary-key-order
Browse files Browse the repository at this point in the history
Fix SchemaManagerFunctionalTestCase::testSwitchPrimaryKeyOrder()
  • Loading branch information
morozov authored Mar 4, 2025
2 parents 98cf3a2 + 4093dd9 commit be9c119
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/Functional/Schema/SchemaManagerFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1462,8 +1462,21 @@ public function testChangeIndexWithForeignKeys(): void
self::assertTrue($child->hasIndex('idx_2'));
}

/** @throws Exception */
public function testSwitchPrimaryKeyOrder(): void
{
$platform = $this->connection->getDatabasePlatform();

if (
$platform instanceof DB2Platform
|| $platform instanceof OraclePlatform
|| $platform instanceof SQLServerPlatform
) {
self::markTestIncomplete(
'Dropping primary key constraint on the currently used database platform is not implemented.',
);
}

$prototype = new Table('test_switch_pk_order');
$prototype->addColumn('foo_id', Types::INTEGER);
$prototype->addColumn('bar_id', Types::INTEGER);
Expand All @@ -1481,11 +1494,13 @@ public function testSwitchPrimaryKeyOrder(): void
$schemaManager->introspectTable('test_switch_pk_order'),
$table,
);
self::assertFalse($diff->isEmpty());
$schemaManager->alterTable($diff);

$table = $schemaManager->introspectTable('test_switch_pk_order');
$primaryKey = $table->getPrimaryKey();
self::assertNotNull($primaryKey);
self::assertSame(['foo_id', 'bar_id'], array_map('strtolower', $primaryKey->getColumns()));
self::assertSame(['bar_id', 'foo_id'], array_map('strtolower', $primaryKey->getColumns()));
}

public function testDropColumnWithDefault(): void
Expand Down

0 comments on commit be9c119

Please sign in to comment.