Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
vencakrecl committed Jun 14, 2024
1 parent 685e46a commit cc2b82f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/Tests/ORM/Tools/SchemaToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_D87F7E0C1E5D0459')->getOptions());
}
}

#[Table('test')]
#[Entity]
class TestEntityWithJoinColumnWithOptions
{
#[Id]
#[Column]
private int $id;

#[OneToOne(targetEntity: TestEntityWithJoinColumnWithOptionsRelation::class)]
#[JoinColumn(options: ['deferrable' => true, 'deferred' => true])]
private TestEntityWithJoinColumnWithOptionsRelation $test;
}

#[Entity]
class TestEntityWithJoinColumnWithOptionsRelation
{
#[Id]
#[Column]
private int $id;
}

#[Table(options: ['foo' => 'bar', 'baz' => ['key' => 'val']])]
Expand Down

0 comments on commit cc2b82f

Please sign in to comment.