Skip to content
Permalink
Browse files

Implement tests for new dbo source methods for additional table and f…

…ield parameters support
  • Loading branch information...
skie committed Sep 29, 2009
1 parent 070bbb5 commit a445a120207dcfbc6a1ee384f330b2cd18007c3b
Showing with 61 additions and 0 deletions.
  1. +61 −0 cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
@@ -599,5 +599,66 @@ function testAlterSchemaIndexes() {
$this->db->query($this->db->dropSchema($schema1));
}
/**
* testReadTableParameters method
*
* @access public
* @return void
*/
function testReadTableParameters() {
$this->db->cacheSources = $this->db->testing = false;
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;');
$result = $this->db->readTableParameters('tinyint');
$expected = array(
'charset' => 'utf8',
'collate' => 'utf8_unicode_ci',
'engine' => 'InnoDB');
$this->assertEqual($result, $expected);
$this->db->query('DROP TABLE ' . $this->db->fullTableName('tinyint'));
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
$result = $this->db->readTableParameters('tinyint');
$expected = array(
'charset' => 'cp1250',
'collate' => 'cp1250_general_ci',
'engine' => 'MyISAM');
$this->assertEqual($result, $expected);
$this->db->query('DROP TABLE ' . $this->db->fullTableName('tinyint'));
}
/**
* testBuildTableParameters method
*
* @access public
* @return void
*/
function testBuildTableParameters() {
$this->db->cacheSources = $this->db->testing = false;
$data = array(
'charset' => 'utf8',
'collate' => 'utf8_unicode_ci',
'engine' => 'InnoDB');
$result = $this->db->buildTableParameters($data);
$expected = array(
'DEFAULT CHARSET=utf8',
'COLLATE=utf8_unicode_ci',
'ENGINE=InnoDB');
$this->assertEqual($result, $expected);
}
/**
* testBuildTableParameters method
*
* @access public
* @return void
*/
function testGetCharsetName() {
$this->db->cacheSources = $this->db->testing = false;
$result = $this->db->getCharsetName('utf8_unicode_ci');
$this->assertEqual($result, 'utf8');
$result = $this->db->getCharsetName('cp1250_general_ci');
$this->assertEqual($result, 'cp1250');
}
}
?>

0 comments on commit a445a12

Please sign in to comment.
You can’t perform that action at this time.