Skip to content

Commit

Permalink
test: add test for sql result
Browse files Browse the repository at this point in the history
  • Loading branch information
vencakrecl committed Jun 18, 2024
1 parent 2f0756c commit e882b6d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Tests/ORM/Tools/SchemaToolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,6 +45,7 @@

use function count;
use function current;
use function end;

class SchemaToolTest extends OrmTestCase
{
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -421,6 +427,7 @@ class TestEntityWithJoinColumnWithOptions
private TestEntityWithJoinColumnWithOptionsRelation $test;
}

#[Table('test_relation')]
#[Entity]
class TestEntityWithJoinColumnWithOptionsRelation
{
Expand Down

0 comments on commit e882b6d

Please sign in to comment.