From fa25d4b2270f6ef4baa5cba293d25f1f3b30d759 Mon Sep 17 00:00:00 2001 From: Venca Krecl Date: Fri, 14 Jun 2024 13:19:56 +0200 Subject: [PATCH] test: add test --- tests/Tests/ORM/Tools/SchemaToolTest.php | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index a1f3e77d70c..cd99e4c0cdb 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -391,6 +391,42 @@ public function testLoadUniqueConstraintWithoutName(): void self::assertTrue($tableIndex->isUnique()); self::assertSame(['field', 'anotherField'], $tableIndex->getColumns()); } + + public function testJoinColumnWithOptions(): void + { + $em = $this->getTestEntityManager(); + $schemaTool = new SchemaTool($em); + + $classes = [ + $em->getClassMetadata(TestEntityWithJoinColumnWithOptions::class), + $em->getClassMetadata(TestEntityWithJoinColumnWithOptionsRelation::class), + ]; + + $schema = $schemaTool->getSchemaFromMetadata($classes); + + self::assertSame(['deferrable' => true, 'deferred' => true], $schema->getTable('test')->getForeignKey('FK_D87F7E0CD87F7E0C')->getOptions()); + } +} + +#[Table('test')] +#[Entity] +class TestEntityWithJoinColumnWithOptions +{ + #[Id] + #[Column] + private int $id; + + #[OneToOne(targetEntity: TestEntityWithJoinColumnWithOptionsRelation::class)] + #[JoinColumn(name: 'test', referencedColumnName: 'id', options: ['deferrable' => true, 'deferred' => true])] + private TestEntityWithJoinColumnWithOptionsRelation $test; +} + +#[Entity] +class TestEntityWithJoinColumnWithOptionsRelation +{ + #[Id] + #[Column] + private int $id; } #[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])]