5
5
namespace Doctrine \Tests \ORM \Tools ;
6
6
7
7
use Doctrine \Common \Collections \Collection ;
8
+ use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
8
9
use Doctrine \ORM \Mapping \ClassMetadata ;
9
10
use Doctrine \ORM \Mapping \Column ;
10
11
use Doctrine \ORM \Mapping \Entity ;
@@ -404,7 +405,13 @@ public function testJoinColumnWithOptions(): void
404
405
405
406
$ schema = $ schemaTool ->getSchemaFromMetadata ($ classes );
406
407
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 ]);
408
415
}
409
416
}
410
417
@@ -418,9 +425,14 @@ class TestEntityWithJoinColumnWithOptions
418
425
419
426
#[OneToOne(targetEntity: TestEntityWithJoinColumnWithOptionsRelation::class)]
420
427
#[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 ;
422
433
}
423
434
435
+ #[Table('test_relation ' )]
424
436
#[Entity]
425
437
class TestEntityWithJoinColumnWithOptionsRelation
426
438
{
0 commit comments