Browse Source

Don't drop table if it already exists.

Dropping a table during the tests causes SQLite to fail.
Mark Story 11 years ago
parent
commit
240a9cb2f8
1 changed files with 11 additions and 11 deletions
  1. 11 11
      tests/TestCase/Database/Schema/SqliteSchemaTest.php

+ 11 - 11
tests/TestCase/Database/Schema/SqliteSchemaTest.php

@@ -232,6 +232,16 @@ CONSTRAINT "author_idx" FOREIGN KEY ("author_id") REFERENCES "schema_authors" ("
 SQL;
         $connection->execute($table);
         $connection->execute('CREATE INDEX "created_idx" ON "schema_articles" ("created")');
+
+        $sql = <<<SQL
+CREATE TABLE schema_composite (
+    "id" INTEGER NOT NULL,
+    "site_id" INTEGER NOT NULL,
+    "name" VARCHAR(255),
+    PRIMARY KEY("id", "site_id")
+);
+SQL;
+        $connection->execute($sql);
     }
 
     /**
@@ -336,20 +346,10 @@ SQL;
      */
     public function testDescribeTableCompositeKey()
     {
-        $this->_needsConnection();
         $connection = ConnectionManager::get('test');
-        $sql = <<<SQL
-CREATE TABLE schema_composite (
-    "id" INTEGER NOT NULL,
-    "site_id" INTEGER NOT NULL,
-    "name" VARCHAR(255),
-    PRIMARY KEY("id", "site_id")
-);
-SQL;
-        $connection->execute($sql);
+        $this->_createTables($connection);
         $schema = new SchemaCollection($connection);
         $result = $schema->describe('schema_composite');
-        $connection->execute('DROP TABLE schema_composite');
 
         $this->assertEquals(['id', 'site_id'], $result->primaryKey());
         $this->assertNull($result->column('site_id')['autoIncrement'], 'site_id should not be autoincrement');