diff --git a/tests/TestCase/Db/Adapter/PhinxAdapterTest.php b/tests/TestCase/Db/Adapter/PhinxAdapterTest.php index 58038ff1..0f38d497 100644 --- a/tests/TestCase/Db/Adapter/PhinxAdapterTest.php +++ b/tests/TestCase/Db/Adapter/PhinxAdapterTest.php @@ -108,12 +108,12 @@ public function testRollbackTransaction() public function testQuoteTableName() { - $this->assertEquals('`test_table`', $this->adapter->quoteTableName('test_table')); + $this->assertEquals('"test_table"', $this->adapter->quoteTableName('test_table')); } public function testQuoteColumnName() { - $this->assertEquals('`test_column`', $this->adapter->quoteColumnName('test_column')); + $this->assertEquals('"test_column"', $this->adapter->quoteColumnName('test_column')); } public function testCreateTable() @@ -296,10 +296,10 @@ public function testCreateTableWithIndexesAndForeignKey() $this->assertTrue($this->adapter->hasForeignKey('tbl_child', ['master_id'])); $row = $this->adapter->fetchRow( - "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'" + "SELECT * FROM sqlite_master WHERE \"type\" = 'table' AND \"tbl_name\" = 'tbl_child'" ); $this->assertStringContainsString( - 'CONSTRAINT `fk_master_id` FOREIGN KEY (`master_id`) REFERENCES `tbl_master` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION', + 'CONSTRAINT "fk_master_id" FOREIGN KEY ("master_id") REFERENCES "tbl_master" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION', $row['sql'] ); } @@ -323,10 +323,10 @@ public function testCreateTableWithoutAutoIncrementingPrimaryKeyAndWithForeignKe $this->assertTrue($this->adapter->hasForeignKey('tbl_child', ['master_id'])); $row = $this->adapter->fetchRow( - "SELECT * FROM sqlite_master WHERE `type` = 'table' AND `tbl_name` = 'tbl_child'" + "SELECT * FROM sqlite_master WHERE \"type\" = 'table' AND \"tbl_name\" = 'tbl_child'" ); $this->assertStringContainsString( - 'CONSTRAINT `fk_master_id` FOREIGN KEY (`master_id`) REFERENCES `tbl_master` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION', + 'CONSTRAINT "fk_master_id" FOREIGN KEY ("master_id") REFERENCES "tbl_master" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION', $row['sql'] ); } @@ -1115,7 +1115,7 @@ public function testDumpCreateTable() ->save(); $expectedOutput = <<<'OUTPUT' -CREATE TABLE `table1` (`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `column1` VARCHAR NOT NULL, `column2` INTEGER NULL, `column3` VARCHAR NULL DEFAULT 'test'); +CREATE TABLE "table1" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "column1" VARCHAR NOT NULL, "column2" INTEGER NULL, "column3" VARCHAR NULL DEFAULT 'test'); OUTPUT; $actualOutput = join("\n", $this->out->messages()); $this->assertStringContainsString($expectedOutput, $actualOutput, 'Passing the --dry-run option does not dump create table query to the output'); @@ -1147,9 +1147,9 @@ public function testDumpInsert() ]); $expectedOutput = <<<'OUTPUT' -INSERT INTO `table1` (`string_col`) VALUES ('test data'); -INSERT INTO `table1` (`string_col`) VALUES (null); -INSERT INTO `table1` (`int_col`) VALUES (23); +INSERT INTO "table1" ("string_col") VALUES ('test data'); +INSERT INTO "table1" ("string_col") VALUES (null); +INSERT INTO "table1" ("int_col") VALUES (23); OUTPUT; $actualOutput = join("\n", $this->out->messages()); $actualOutput = preg_replace("/\r\n|\r/", "\n", $actualOutput); // normalize line endings for Windows @@ -1186,7 +1186,7 @@ public function testDumpBulkinsert() ]); $expectedOutput = <<<'OUTPUT' -INSERT INTO `table1` (`string_col`, `int_col`) VALUES ('test_data1', 23), (null, 42); +INSERT INTO "table1" ("string_col", "int_col") VALUES ('test_data1', 23), (null, 42); OUTPUT; $actualOutput = join("\n", $this->out->messages()); $this->assertStringContainsString($expectedOutput, $actualOutput, 'Passing the --dry-run option doesn\'t dump the bulkinsert to the output'); @@ -1216,8 +1216,8 @@ public function testDumpCreateTableAndThenInsert() ])->save(); $expectedOutput = <<<'OUTPUT' -CREATE TABLE `table1` (`column1` VARCHAR NOT NULL, `column2` INTEGER NULL, PRIMARY KEY (`column1`)); -INSERT INTO `table1` (`column1`, `column2`) VALUES ('id1', 1); +CREATE TABLE "table1" ("column1" VARCHAR NOT NULL, "column2" INTEGER NULL, PRIMARY KEY ("column1")); +INSERT INTO "table1" ("column1", "column2") VALUES ('id1', 1); OUTPUT; $actualOutput = join("\n", $this->out->messages()); $actualOutput = preg_replace("/\r\n|\r/", "\n", $actualOutput); // normalize line endings for Windows @@ -1618,7 +1618,7 @@ public function testForeignKeyReferenceCorrectAfterRenameColumn() $sql = $row['sql']; } } - $this->assertStringContainsString("REFERENCES `{$refTable->getName()}` (`id`)", $sql); + $this->assertStringContainsString("REFERENCES \"{$refTable->getName()}\" (\"id\")", $sql); } public function testForeignKeyReferenceCorrectAfterChangeColumn() @@ -1645,7 +1645,7 @@ public function testForeignKeyReferenceCorrectAfterChangeColumn() $sql = $row['sql']; } } - $this->assertStringContainsString("REFERENCES `{$refTable->getName()}` (`id`)", $sql); + $this->assertStringContainsString("REFERENCES \"{$refTable->getName()}\" (\"id\")", $sql); } public function testForeignKeyReferenceCorrectAfterRemoveColumn() @@ -1666,13 +1666,13 @@ public function testForeignKeyReferenceCorrectAfterRemoveColumn() $this->assertFalse($this->adapter->hasTable("tmp_{$refTable->getName()}")); $this->assertFalse($this->adapter->hasColumn($refTable->getName(), $refTableColumnToRemove)); - $rows = $this->adapter->fetchAll('select * from sqlite_master where `type` = \'table\''); + $rows = $this->adapter->fetchAll('select * from sqlite_master where "type" = \'table\''); foreach ($rows as $row) { if ($row['tbl_name'] === $table->getName()) { $sql = $row['sql']; } } - $this->assertStringContainsString("REFERENCES `{$refTable->getName()}` (`id`)", $sql); + $this->assertStringContainsString("REFERENCES \"{$refTable->getName()}\" (\"id\")", $sql); } public function testForeignKeyReferenceCorrectAfterChangePrimaryKey() @@ -1702,6 +1702,6 @@ public function testForeignKeyReferenceCorrectAfterChangePrimaryKey() $sql = $row['sql']; } } - $this->assertStringContainsString("REFERENCES `{$refTable->getName()}` (`id`)", $sql); + $this->assertStringContainsString("REFERENCES \"{$refTable->getName()}\" (\"id\")", $sql); } } diff --git a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php index 7b7655ad..7f0a7acb 100644 --- a/tests/TestCase/Db/Adapter/SqliteAdapterTest.php +++ b/tests/TestCase/Db/Adapter/SqliteAdapterTest.php @@ -527,12 +527,12 @@ public function testAddColumnWithDefaultEmptyString() $this->assertEquals("''", $rows[1]['dflt_value']); } - public static function irregularCreateTableProvider() + public static function irregularCreateTableProvider(): array { return [ ["CREATE TABLE \"users\"\n( \"id\" INTEGER NOT NULL )", ['id', 'foo']], ['CREATE TABLE users ( id INTEGER NOT NULL )', ['id', 'foo']], - ["CREATE TABLE `users` (`id` INTEGER NOT NULL )", ['id', 'foo']], + ['CREATE TABLE `users` (`id` INTEGER NOT NULL )', ['id', 'foo']], ["CREATE TABLE [users]\n(\nid INTEGER NOT NULL)", ['id', 'foo']], ["CREATE TABLE \"users\" ([id] \n INTEGER NOT NULL\n, \"bar\" INTEGER)", ['id', 'bar', 'foo']], ];