Browse Source

Remove conditionals in tests.

These conditionals were required before because the table was left
behind between test runs. When test order was modified tests could fail.
Mark Story 10 years ago
parent
commit
db6869d33e
1 changed files with 13 additions and 12 deletions
  1. 13 12
      tests/TestCase/TestSuite/TestFixtureTest.php

+ 13 - 12
tests/TestCase/TestSuite/TestFixtureTest.php

@@ -281,18 +281,15 @@ class TestFixtureTest extends TestCase
     public function testInitNoImportNoFields()
     {
         $db = ConnectionManager::get('test');
-        $collection = $db->schemaCollection();
-        if (!in_array('letters', $collection->listTables())) {
-            $table = new Table('letters', [
-                'id' => ['type' => 'integer'],
-                'letter' => ['type' => 'string', 'length' => 1]
-            ]);
-            $table->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
-            $sql = $table->createSql($db);
-
-            foreach ($sql as $stmt) {
-                $db->execute($stmt);
-            }
+        $table = new Table('letters', [
+            'id' => ['type' => 'integer'],
+            'letter' => ['type' => 'string', 'length' => 1]
+        ]);
+        $table->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
+        $sql = $table->createSql($db);
+
+        foreach ($sql as $stmt) {
+            $db->execute($stmt);
         }
 
         $fixture = new LettersFixture();
@@ -306,6 +303,10 @@ class TestFixtureTest extends TestCase
             ->method('execute');
         $this->assertTrue($fixture->create($db));
         $this->assertTrue($fixture->drop($db));
+
+        // Cleanup.
+        $db = ConnectionManager::get('test');
+        $db->execute('DROP TABLE letters');
     }
 
     /**