Add consistent handling of the users test table to the Pdo adapter tests
authorChuck Hagenbuch <chuck@horde.org>
Tue, 5 Jan 2010 19:24:37 +0000 (14:24 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Thu, 7 Jan 2010 03:19:54 +0000 (22:19 -0500)
framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php
framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php

index ce5b279..3238d7d 100644 (file)
@@ -410,8 +410,9 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
 
     public function testUnabstractedDatabaseDependentTypes()
     {
-        $this->_conn->delete('DELETE FROM users');
+        $this->_createTestUsersTable();
 
+        $this->_conn->delete('DELETE FROM users');
         $this->_conn->addColumn('users', 'intelligence_quotient', 'tinyint');
         $this->_conn->insert('INSERT INTO users (intelligence_quotient) VALUES (300)');
 
@@ -968,6 +969,21 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
         } catch (Exception $e) {}
     }
 
+    protected function _createTestUsersTable()
+    {
+        $table = $this->_conn->createTable('users');
+          $table->column('company_id',  'integer',  array('limit' => 11));
+          $table->column('name',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('first_name',  'string',   array('limit' => 40, 'default' => ''));
+          $table->column('approved',    'boolean',  array('default' => true));
+          $table->column('type',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('created_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('created_on',  'date',     array('default' => '0000-00-00'));
+          $table->column('updated_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('updated_on',  'date',     array('default' => '0000-00-00'));
+        $table->end();
+    }
+
     /**
      * drop test tables
      */
@@ -977,6 +993,9 @@ class Horde_Db_Adapter_Pdo_MysqlTest extends PHPUnit_Framework_TestCase
             $this->_conn->dropTable('unit_tests');
         } catch (Exception $e) {}
         try {
+            $this->_conn->dropTable('users');
+        } catch (Exception $e) {}
+        try {
             $this->_conn->dropTable('sports');
         } catch (Exception $e) {}
         try {
index 0e23d96..a5023e8 100644 (file)
@@ -839,6 +839,21 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
         } catch (Exception $e) {}
     }
 
+    protected function _createTestUsersTable()
+    {
+        $table = $this->_conn->createTable('users');
+          $table->column('company_id',  'integer',  array('limit' => 11));
+          $table->column('name',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('first_name',  'string',   array('limit' => 40, 'default' => ''));
+          $table->column('approved',    'boolean',  array('default' => true));
+          $table->column('type',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('created_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('created_on',  'date',     array('default' => '0000-00-00'));
+          $table->column('updated_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('updated_on',  'date',     array('default' => '0000-00-00'));
+        $table->end();
+    }
+
     /**
      * drop test tables
      */
@@ -848,6 +863,9 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase
             $this->_conn->dropTable('unit_tests');
         } catch (Exception $e) {}
         try {
+            $this->_conn->dropTable('users');
+        } catch (Exception $e) {}
+        try {
             $this->_conn->dropTable('sports');
         } catch (Exception $e) {}
         try {
index 65db9ed..4df2c77 100644 (file)
@@ -855,6 +855,21 @@ class Horde_Db_Adapter_Pdo_SqliteTest extends PHPUnit_Framework_TestCase
         } catch (Exception $e) {}
     }
 
+    protected function _createTestUsersTable()
+    {
+        $table = $this->_conn->createTable('users');
+          $table->column('company_id',  'integer',  array('limit' => 11));
+          $table->column('name',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('first_name',  'string',   array('limit' => 40, 'default' => ''));
+          $table->column('approved',    'boolean',  array('default' => true));
+          $table->column('type',        'string',   array('limit' => 255, 'default' => ''));
+          $table->column('created_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('created_on',  'date',     array('default' => '0000-00-00'));
+          $table->column('updated_at',  'datetime', array('default' => '0000-00-00 00:00:00'));
+          $table->column('updated_on',  'date',     array('default' => '0000-00-00'));
+        $table->end();
+    }
+
     /**
      * Get a column by name
      */