From e882b6dcafc0f1abcd6aa2c052d18332e467601e Mon Sep 17 00:00:00 2001 From: Venca Krecl Date: Tue, 18 Jun 2024 14:46:51 +0200 Subject: [PATCH] test: add test for sql result --- tests/Tests/ORM/Tools/SchemaToolTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Tests/ORM/Tools/SchemaToolTest.php b/tests/Tests/ORM/Tools/SchemaToolTest.php index 16aaad94869..defdc756cb5 100644 --- a/tests/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Tests/ORM/Tools/SchemaToolTest.php @@ -5,6 +5,7 @@ namespace Doctrine\Tests\ORM\Tools; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; @@ -44,6 +45,7 @@ use function count; use function current; +use function end; class SchemaToolTest extends OrmTestCase { @@ -405,6 +407,10 @@ public function testJoinColumnWithOptions(): void $schema = $schemaTool->getSchemaFromMetadata($classes); self::assertSame(['deferrable' => true, 'deferred' => true], $schema->getTable('test')->getForeignKey('FK_D87F7E0C1E5D0459')->getOptions()); + + $sql = $schema->toSql(new PostgreSQLPlatform()); + + $this->assertSame('ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C1E5D0459 FOREIGN KEY (test_id) REFERENCES test_relation (id) DEFERRABLE INITIALLY DEFERRED', end($sql)); } } @@ -421,6 +427,7 @@ class TestEntityWithJoinColumnWithOptions private TestEntityWithJoinColumnWithOptionsRelation $test; } +#[Table('test_relation')] #[Entity] class TestEntityWithJoinColumnWithOptionsRelation {