55namespace Doctrine \Tests \ORM \Tools ;
66
77use Doctrine \Common \Collections \Collection ;
8+ use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
89use Doctrine \ORM \Mapping \ClassMetadata ;
910use Doctrine \ORM \Mapping \Column ;
1011use Doctrine \ORM \Mapping \Entity ;
@@ -404,7 +405,13 @@ public function testJoinColumnWithOptions(): void
404405
405406 $ schema = $ schemaTool ->getSchemaFromMetadata ($ classes );
406407
407- self ::assertSame (['deferrable ' => true , 'deferred ' => true ], $ schema ->getTable ('test ' )->getForeignKey ('FK_D87F7E0C1E5D0459 ' )->getOptions ());
408+ self ::assertSame (['deferrable ' => true , 'deferred ' => true ], $ schema ->getTable ('test ' )->getForeignKey ('FK_D87F7E0C331521C6 ' )->getOptions ());
409+ self ::assertSame ([], $ schema ->getTable ('test ' )->getForeignKey ('FK_D87F7E0C21A08E28 ' )->getOptions ());
410+
411+ $ sql = $ schema ->toSql (new PostgreSQLPlatform ());
412+
413+ $ this ->assertSame ('ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C331521C6 FOREIGN KEY (testRelation1_id) REFERENCES test_relation (id) DEFERRABLE INITIALLY DEFERRED ' , $ sql [count ($ sql ) - 2 ]);
414+ $ this ->assertSame ('ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C21A08E28 FOREIGN KEY (testRelation2_id) REFERENCES test_relation (id) NOT DEFERRABLE INITIALLY IMMEDIATE ' , $ sql [count ($ sql ) - 1 ]);
408415 }
409416}
410417
@@ -418,9 +425,14 @@ class TestEntityWithJoinColumnWithOptions
418425
419426 #[OneToOne(targetEntity: TestEntityWithJoinColumnWithOptionsRelation::class)]
420427 #[JoinColumn(options: ['deferrable ' => true , 'deferred ' => true ])]
421- private TestEntityWithJoinColumnWithOptionsRelation $ test ;
428+ private TestEntityWithJoinColumnWithOptionsRelation $ testRelation1 ;
429+
430+ #[OneToOne(targetEntity: TestEntityWithJoinColumnWithOptionsRelation::class)]
431+ #[JoinColumn]
432+ private TestEntityWithJoinColumnWithOptionsRelation $ testRelation2 ;
422433}
423434
435+ #[Table('test_relation ' )]
424436#[Entity]
425437class TestEntityWithJoinColumnWithOptionsRelation
426438{
0 commit comments