55namespace Doctrine \Tests \ORM \Functional \Ticket ;
66
77use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
8+ use Doctrine \DBAL \Schema \Index ;
89use Doctrine \ORM \Mapping as ORM ;
910use Doctrine \Tests \OrmFunctionalTestCase ;
1011use PHPUnit \Framework \Attributes \Group ;
1112
13+ use function method_exists ;
1214use function reset ;
1315
1416class 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)]
5488class GH11982ColumnIndex
0 commit comments