Skip to content

Commit

Permalink
Implement tests for new dbo source methods for additional table and f…
Browse files Browse the repository at this point in the history
…ield parameters support
  • Loading branch information
skie committed Sep 29, 2009
1 parent 070bbb5 commit a445a12
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
Expand Up @@ -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.