Skip to content

Commit de7140e

Browse files
authored
Address deprecations from doctrine/dbal (#12098)
- Non-standard flags are deprecated. - Index::getColumns() is deprecated.
1 parent f3371e1 commit de7140e

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

tests/Tests/ORM/Functional/Ticket/GH11982Test.php

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
namespace Doctrine\Tests\ORM\Functional\Ticket;
66

77
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
8+
use Doctrine\DBAL\Schema\Index;
89
use Doctrine\ORM\Mapping as ORM;
910
use Doctrine\Tests\OrmFunctionalTestCase;
1011
use PHPUnit\Framework\Attributes\Group;
1112

13+
use function method_exists;
1214
use function reset;
1315

1416
class GH11982Test extends OrmFunctionalTestCase
@@ -29,6 +31,38 @@ public function testSchema(): void
2931
self::markTestSkipped('This test does not work on psql.');
3032
}
3133

34+
if (! method_exists(Index::class, 'getIndexedColumns')) {
35+
self::markTestSkipped('This test requires doctrine/dbal >=4.3');
36+
}
37+
38+
$indexes = $this->createSchemaManager()
39+
->introspectTable('GH11982ColumnIndex')
40+
->getIndexes();
41+
42+
self::assertCount(3, $indexes); // primary + 2 custom indexes
43+
self::assertArrayHasKey('class_idx', $indexes);
44+
45+
unset($indexes['primary']);
46+
unset($indexes['class_idx']);
47+
$unnamedIndexColumns = reset($indexes)->getIndexedColumns();
48+
self::assertCount(1, $unnamedIndexColumns);
49+
self::assertEquals(
50+
'indexTrue',
51+
$unnamedIndexColumns[0]->getColumnName()->toString(),
52+
);
53+
}
54+
55+
#[Group('GH-11982')]
56+
public function testSchemaLegacyDbal(): void
57+
{
58+
if ($this->_em->getConnection()->getDatabasePlatform() instanceof PostgreSQLPlatform) {
59+
self::markTestSkipped('This test does not work on psql.');
60+
}
61+
62+
if (method_exists(Index::class, 'getIndexedColumns')) {
63+
self::markTestSkipped('This test requires doctrine/dbal <4.3');
64+
}
65+
3266
$indexes = $this->createSchemaManager()
3367
->introspectTable('GH11982ColumnIndex')
3468
->getIndexes();
@@ -48,7 +82,7 @@ public function testSchema(): void
4882
#[ORM\Index(
4983
name: 'class_idx',
5084
fields: ['classIndex'],
51-
flags: ['test'],
85+
flags: ['fulltext'],
5286
options: ['test'],
5387
)]
5488
class GH11982ColumnIndex

0 commit comments

Comments
 (0)