From: Chuck Hagenbuch Date: Thu, 24 Dec 2009 21:26:31 +0000 (-0500) Subject: Clean up handling of the users table X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d64b4d88c3d6b8df4fe15e1d5bd2a3e8cbbc924f;p=horde.git Clean up handling of the users table --- diff --git a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php index a481258a2..58360ce29 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqliTest.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqliTest.php @@ -319,17 +319,7 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase */ public function testNativeDecimalInsertManualVsAutomatic() { - $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(); + $this->_createTestUsersTable(); $correctValue = 12345678901234567890.0123456789; @@ -357,23 +347,11 @@ class Horde_Db_Adapter_MysqliTest 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() { - $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(); + $this->_createTestUsersTable(); $this->_conn->addColumn("users", "last_name", 'string'); $this->_conn->addColumn("users", "bio", 'text'); @@ -410,6 +388,7 @@ class Horde_Db_Adapter_MysqliTest extends PHPUnit_Framework_TestCase public function testUnabstractedDatabaseDependentTypes() { + $this->_createTestUsersTable(); $this->_conn->delete('DELETE FROM users'); $this->_conn->addColumn('users', 'intelligence_quotient', 'tinyint'); @@ -968,6 +947,21 @@ class Horde_Db_Adapter_MysqliTest 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 +971,9 @@ class Horde_Db_Adapter_MysqliTest 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 {