From 663efa9ee13e73b71386cb814f2f02b206539e51 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 21 Mar 2025 22:58:31 -0700 Subject: [PATCH] Remove duplicate schema management tests 1. NewPrimaryKeyWithNewAutoIncrementColumnTest duplicates AlterTableTest#testAddPrimaryKeyOnNewAutoIncrementColumn() 2. DBAL168Test doesn't fail if the code change it covers is reverted, although other tests do 3. DBAL510Test doesn't cover any specific requirement --- ...imaryKeyWithNewAutoIncrementColumnTest.php | 70 ------------------- tests/Functional/Ticket/DBAL168Test.php | 26 ------- tests/Functional/Ticket/DBAL510Test.php | 40 ----------- 3 files changed, 136 deletions(-) delete mode 100644 tests/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php delete mode 100644 tests/Functional/Ticket/DBAL168Test.php delete mode 100644 tests/Functional/Ticket/DBAL510Test.php diff --git a/tests/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php b/tests/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php deleted file mode 100644 index 45da1a17dbb..00000000000 --- a/tests/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php +++ /dev/null @@ -1,70 +0,0 @@ -getPlatform() instanceof AbstractMySQLPlatform) { - return; - } - - self::markTestSkipped('Restricted to MySQL.'); - } - - /** - * Ensures that the primary key is created within the same "alter table" statement that an auto-increment column - * is added to the table as part of the new primary key. - * - * Before the fix for this problem this resulted in a database error: (at least on mysql) - * SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto - * column and it must be defined as a key - */ - public function testAlterPrimaryKeyToAutoIncrementColumn(): void - { - $this->dropTableIfExists('dbal2807'); - - $schemaManager = $this->connection->createSchemaManager(); - $schema = $schemaManager->introspectSchema(); - - $table = $schema->createTable('dbal2807'); - $table->addColumn('initial_id', Types::INTEGER); - $table->setPrimaryKey(['initial_id']); - - $schemaManager->createTable($table); - - $newSchema = clone $schema; - $newTable = $newSchema->getTable($table->getName()); - $newTable->addColumn('new_id', Types::INTEGER, ['autoincrement' => true]); - $newTable->dropPrimaryKey(); - $newTable->setPrimaryKey(['new_id']); - - $diff = $schemaManager->createComparator() - ->compareSchemas($schema, $newSchema); - - $schemaManager->alterSchema($diff); - - $validationSchema = $schemaManager->introspectSchema(); - $validationTable = $validationSchema->getTable($table->getName()); - - self::assertTrue($validationTable->hasColumn('new_id')); - self::assertTrue($validationTable->getColumn('new_id')->getAutoincrement()); - - $primaryKey = $validationTable->getPrimaryKey(); - self::assertNotNull($primaryKey); - self::assertSame(['new_id'], $primaryKey->getColumns()); - } - - private function getPlatform(): AbstractPlatform - { - return $this->connection->getDatabasePlatform(); - } -} diff --git a/tests/Functional/Ticket/DBAL168Test.php b/tests/Functional/Ticket/DBAL168Test.php deleted file mode 100644 index 79318875edf..00000000000 --- a/tests/Functional/Ticket/DBAL168Test.php +++ /dev/null @@ -1,26 +0,0 @@ -addColumn('id', Types::INTEGER); - $table->addColumn('parent_id', Types::INTEGER); - $table->setPrimaryKey(['id']); - $table->addForeignKeyConstraint('domains', ['parent_id'], ['id']); - - $this->connection->createSchemaManager()->createTable($table); - $table = $this->connection->createSchemaManager()->introspectTable('domains'); - - self::assertEquals('domains', $table->getName()); - } -} diff --git a/tests/Functional/Ticket/DBAL510Test.php b/tests/Functional/Ticket/DBAL510Test.php deleted file mode 100644 index 3897f72fbce..00000000000 --- a/tests/Functional/Ticket/DBAL510Test.php +++ /dev/null @@ -1,40 +0,0 @@ -connection->getDatabasePlatform() instanceof PostgreSQLPlatform) { - return; - } - - self::markTestSkipped('PostgreSQL only test'); - } - - public function testSearchPathSchemaChanges(): void - { - $table = new Table('dbal510tbl'); - $table->addColumn('id', Types::INTEGER); - $table->setPrimaryKey(['id']); - - $this->dropAndCreateTable($table); - - $schemaManager = $this->connection->createSchemaManager(); - $onlineTable = $schemaManager->introspectTable('dbal510tbl'); - - self::assertTrue( - $schemaManager->createComparator() - ->compareTables($onlineTable, $table) - ->isEmpty(), - ); - } -}