Skip to content

Commit fb96d1a

Browse files
committed
Simplify CustomIntrospectionTest
1 parent ebe1520 commit fb96d1a

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

tests/Functional/Schema/CustomIntrospectionTest.php

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
namespace Doctrine\DBAL\Tests\Functional\Schema;
66

7-
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
8-
use Doctrine\DBAL\Platforms\AbstractPlatform;
9-
use Doctrine\DBAL\Schema\AbstractSchemaManager;
10-
use Doctrine\DBAL\Schema\Comparator;
7+
use Doctrine\DBAL\Schema\ColumnDiff;
118
use Doctrine\DBAL\Schema\Table;
129
use Doctrine\DBAL\Tests\Functional\Schema\Types\MoneyType;
1310
use Doctrine\DBAL\Tests\FunctionalTestCase;
@@ -25,32 +22,14 @@
2522
*/
2623
class CustomIntrospectionTest extends FunctionalTestCase
2724
{
28-
private AbstractSchemaManager $schemaManager;
29-
30-
private Comparator $comparator;
31-
32-
private AbstractPlatform $platform;
33-
3425
public static function setUpBeforeClass(): void
3526
{
3627
Type::addType('money', MoneyType::class);
3728
}
3829

39-
protected function setUp(): void
40-
{
41-
$this->platform = $this->connection->getDatabasePlatform();
42-
43-
if (! $this->platform instanceof AbstractMySQLPlatform) {
44-
self::markTestSkipped();
45-
}
46-
47-
$this->schemaManager = $this->connection->createSchemaManager();
48-
$this->comparator = $this->schemaManager->createComparator();
49-
}
50-
5130
public function testCustomColumnIntrospection(): void
5231
{
53-
$tableName = 'test_custom_column_introspection';
32+
$tableName = 'test_custom_column_intro';
5433
$table = new Table($tableName);
5534

5635
$table->addColumn('id', 'integer');
@@ -63,18 +42,21 @@ public function testCustomColumnIntrospection(): void
6342

6443
$this->dropAndCreateTable($table);
6544

66-
$onlineTable = $this->schemaManager->introspectTable($tableName);
67-
68-
$diff = $this->comparator->compareTables($table, $onlineTable);
69-
$changedCols = [];
45+
$schemaManager = $this->connection->createSchemaManager();
46+
$onlineTable = $schemaManager->introspectTable($tableName);
47+
$diff = $schemaManager->createComparator()->compareTables($table, $onlineTable);
48+
$changedCols = array_map(
49+
static function (ColumnDiff $columnDiff): ?string {
50+
$column = $columnDiff->getOldColumn();
7051

71-
if (! $diff->isEmpty()) {
72-
$changedCols = array_map(static fn ($c) => $c->getOldColumnName()->getName(), $diff->getModifiedColumns());
73-
}
52+
return $column !== null ? $column->getName() : null;
53+
},
54+
$diff->getModifiedColumns(),
55+
);
7456

7557
self::assertTrue($diff->isEmpty(), sprintf(
7658
'Tables should be identical. Differences detected in %s.',
77-
implode(':', $changedCols),
59+
implode(', ', $changedCols),
7860
));
7961
}
8062
}

0 commit comments

Comments
 (0)