Skip to content

Commit

Permalink
Make these still pass on older MySQL versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Feb 3, 2015
1 parent 2d324d4 commit 202aca9
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions framework/Db/test/Horde/Db/Adapter/MysqlBase.php
Expand Up @@ -231,20 +231,21 @@ public function testNativeDatabaseTypes()
$this->assertEquals(array('name' => 'int', 'limit' => 11), $types['integer']);
}

/**
* @expectedException Horde_Db_Exception
* @expectedExceptionMessage Out of range value for column 'intelligence_quotient' at row 1
*/
public function testUnabstractedDatabaseDependentTypes()
{
$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)');

$jonnyg = (object)$this->_conn->selectOne('SELECT * FROM users');
$this->assertEquals('127', $jonnyg->intelligence_quotient);
try {
$this->_conn->insert('INSERT INTO users (intelligence_quotient) VALUES (300)');
$jonnyg = (object)$this->_conn->selectOne('SELECT * FROM users');
$this->assertEquals('127', $jonnyg->intelligence_quotient);
} catch (Horde_Db_Exception $e) {
if (strpos($e->getMessage(), "Out of range value for column 'intelligence_quotient' at row 1") === false) {
throw $e;
}
}
}

public function testTableAliasLength()
Expand Down Expand Up @@ -319,10 +320,6 @@ public function testChangeColumnPrecisionScale()
$this->assertEquals('decimal(5,2)', $afterChange->getSqlType());
}

/**
* @expectedException Horde_Db_Exception
* @expectedExceptionMessage Out of range value for column 'foo' at row 1
*/
public function testChangeColumnUnsigned()
{
$table = $this->_conn->createTable('testings');
Expand All @@ -334,13 +331,19 @@ public function testChangeColumnUnsigned()

$this->_conn->execute('INSERT INTO testings (id, foo) VALUES (1, -1)');

$this->_conn->changeColumn('testings', 'foo', 'integer', array('unsigned' => true));

$afterChange = $this->_getColumn('testings', 'foo');
$this->assertTrue($afterChange->isUnsigned());

$row = (object)$this->_conn->selectOne('SELECT * FROM testings');
$this->assertEquals(0, $row->foo);
try {
$this->_conn->changeColumn('testings', 'foo', 'integer', array('unsigned' => true));

$afterChange = $this->_getColumn('testings', 'foo');
$this->assertTrue($afterChange->isUnsigned());

$row = (object)$this->_conn->selectOne('SELECT * FROM testings');
$this->assertEquals(0, $row->foo);
} catch (Horde_Db_Exception $e) {
if (strpos($e->getMessage(), "Out of range value for column 'foo' at row 1") === false) {
throw $e;
}
}
}

public function testRenameColumn()
Expand Down

0 comments on commit 202aca9

Please sign in to comment.