Better test table cleanup
authorChuck Hagenbuch <chuck@horde.org>
Wed, 6 Jan 2010 19:25:48 +0000 (14:25 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 7 Jan 2010 03:19:54 +0000 (22:19 -0500)
framework/Db/test/Horde/Db/Adapter/MysqliTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php

index 3b1979d..8f30ee3 100644 (file)
@@ -612,8 +612,6 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('http://www.foreverflying.com/octopus-black7.jpg',
                 $this->_conn->selectValue("SELECT url FROM octopi WHERE id=1"));
 
-        $this->_conn->dropTable('octopi');
-
         // Make sure the old table name isn't still there
         try {
             $sql = "SELECT id FROM octopuses WHERE id = 1";
@@ -640,8 +638,6 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase
 
         $indexes = $this->_conn->indexes('octopi');
         $this->assertEquals('url', $indexes[0]->columns[0]);
-
-        $this->_conn->dropTable('octopi');
     }
 
     public function testDropTable()
@@ -1255,27 +1251,23 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase
      */
     protected function _dropTestTables()
     {
-        try {
-            $this->_conn->dropTable('unit_tests');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('testings');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('users');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('my_sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('schema_info');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('cache_table');
-        } catch (Exception $e) {}
+        $tables = array(
+            'binary_testings',
+            'cache_table',
+            'my_sports',
+            'octopi',
+            'schema_info',
+            'sports',
+            'testings',
+            'unit_tests',
+            'users',
+        );
+
+        foreach ($tables as $table) {
+            try {
+                $this->_conn->dropTable($table);
+            } catch (Exception $e) {}
+        }
     }
 
     protected function _columnNames($tableName)
index 05a568a..d06ace9 100644 (file)
@@ -357,8 +357,6 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
 
         // If these asserts fail, that means the INSERT (create function, or cast to SQL) is broken!
         $this->assertEquals($correctValue, $user->wealth);
-
-        $this->_conn->dropTable('users');
     }
 
     public function testNativeTypes()
@@ -634,8 +632,6 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('http://www.foreverflying.com/octopus-black7.jpg',
                 $this->_conn->selectValue("SELECT url FROM octopi WHERE id=1"));
 
-        $this->_conn->dropTable('octopi');
-
         // Make sure the old table name isn't still there
         try {
             $sql = "SELECT id FROM octopuses WHERE id = 1";
@@ -662,8 +658,6 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
 
         $indexes = $this->_conn->indexes('octopi');
         $this->assertEquals('url', $indexes[0]->columns[0]);
-
-        $this->_conn->dropTable('octopi');
     }
 
     public function testDropTable()
@@ -1278,27 +1272,23 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
      */
     protected function _dropTestTables()
     {
-        try {
-            $this->_conn->dropTable('unit_tests');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('testings');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('users');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('my_sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('schema_info');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('cache_table');
-        } catch (Exception $e) {}
+        $tables = array(
+            'binary_testings',
+            'cache_table',
+            'my_sports',
+            'octopi',
+            'schema_info',
+            'sports',
+            'testings',
+            'unit_tests',
+            'users',
+        );
+
+        foreach ($tables as $table) {
+            try {
+                $this->_conn->dropTable($table);
+            } catch (Exception $e) {}
+        }
     }
 
     protected function _columnNames($tableName)
index 0b2e295..237f0e3 100644 (file)
@@ -536,8 +536,6 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('http://www.foreverflying.com/octopus-black7.jpg',
                 $this->_conn->selectValue("SELECT url FROM octopi WHERE id=1"));
 
-        $this->_conn->dropTable('octopi');
-
         // Make sure the old table name isn't still there
         try {
             $sql = "SELECT id FROM octopuses WHERE id = 1";
@@ -564,8 +562,6 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
 
         $indexes = $this->_conn->indexes('octopi');
         $this->assertEquals('url', $indexes[0]->columns[0]);
-
-        $this->_conn->dropTable('octopi');
     }
 
     public function testDropTable()
@@ -1148,27 +1144,23 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
      */
     protected function _dropTestTables()
     {
-        try {
-            $this->_conn->dropTable('unit_tests');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('testings');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('users');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('my_sports');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('schema_info');
-        } catch (Exception $e) {}
-        try {
-            $this->_conn->dropTable('cache_table');
-        } catch (Exception $e) {}
+        $tables = array(
+            'binary_testings',
+            'cache_table',
+            'my_sports',
+            'octopi',
+            'schema_info',
+            'sports',
+            'testings',
+            'unit_tests',
+            'users',
+        );
+
+        foreach ($tables as $table) {
+            try {
+                $this->_conn->dropTable($table);
+            } catch (Exception $e) {}
+        }
     }
 
     protected function _columnNames($tableName)