From d18c2293caf48423f395fdc1b717b2920cdda193 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Tue, 21 Nov 2023 00:14:43 +0100 Subject: [PATCH] Add a test for sqlite schema tool --- .../SchemaTool/SqliteSchemaToolTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/SchemaTool/SqliteSchemaToolTest.php diff --git a/tests/Doctrine/Tests/ORM/Functional/SchemaTool/SqliteSchemaToolTest.php b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/SqliteSchemaToolTest.php new file mode 100644 index 00000000000..e2c77c150ed --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/SchemaTool/SqliteSchemaToolTest.php @@ -0,0 +1,39 @@ +_em->getConnection()->getDatabasePlatform() instanceof SQLitePlatform) { + self::markTestSkipped('The ' . self::class . ' requires the use of sqlite.'); + } + } + + public function testGetCreateSchemaSql(): void + { + $classes = [ + $this->_em->getClassMetadata(User::class), + ]; + + $tool = new SchemaTool($this->_em); + $sql = $tool->getCreateSchemaSql($classes); + + self::assertEquals('CREATE TABLE readers__user (id INTEGER NOT NULL, PRIMARY KEY(id))', $sql[0]); + self::assertEquals('CREATE TABLE readers__author_reader (author_id INTEGER NOT NULL, reader_id INTEGER NOT NULL, PRIMARY KEY(author_id, reader_id), CONSTRAINT FK_83C36113F675F31B FOREIGN KEY (author_id) REFERENCES readers__user (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_83C361131717D737 FOREIGN KEY (reader_id) REFERENCES readers__user (id) NOT DEFERRABLE INITIALLY IMMEDIATE)', $sql[1]); + self::assertEquals('CREATE INDEX IDX_83C36113F675F31B ON readers__author_reader (author_id)', $sql[2]); + self::assertEquals('CREATE INDEX IDX_83C361131717D737 ON readers__author_reader (reader_id)', $sql[3]); + + self::assertCount(4, $sql); + } +}