From 115d0a7531c7aa32b453d06f29b8ec492a0c3351 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Tue, 5 Jan 2010 14:24:37 -0500 Subject: [PATCH] Add consistent handling of the users test table to the Pdo adapter tests --- .../Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php | 21 ++++++++++++++++++++- .../Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php | 18 ++++++++++++++++++ .../Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php | 15 +++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php index ce5b27999..3238d7d64 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlTest.php @@ -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 { diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php index 0e23d961e..a5023e8fb 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php @@ -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 { diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php index 65db9edb1..4df2c77f5 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php @@ -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 */ -- 2.11.0