Testcase added, refs #2672

This commit is contained in:
Ceeram 2012-03-12 15:12:44 +01:00 committed by mark_story
parent 5033fb60d6
commit a2fb4178fb

View file

@ -642,11 +642,11 @@ class CakeSchemaTest extends CakeTestCase {
*/
public function testSchemaReadWithConfigPrefix() {
$this->skipIf($this->db instanceof Sqlite, 'Cannot open 2 connections to Sqlite');
$db = ConnectionManager::getDataSource('test');
$config = $db->config;
$this->skipIf(!empty($config['prefix']), 'This test can not be executed with datasource prefix set.');
$config['prefix'] = 'schema_test_prefix_';
ConnectionManager::create('schema_prefix', $config);
$read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false));
@ -964,6 +964,54 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertEquals($expected, $compare);
}
/**
* Test comparing with field changed from VARCHAR to DATETIME
*
* @return void
*/
public function testCompareVarcharToDatetime() {
$old = array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'author_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'string', 'null' => true, 'length' => 45),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true)
),
'tableParameters' => array(
'charset' => 'latin1',
'collate' => 'latin1_general_ci'
)
),
);
$new = array(
'posts' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
'author_id' => array('type' => 'integer', 'null' => false),
'title' => array('type' => 'datetime', 'null' => false),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => true)
),
'tableParameters' => array(
'charset' => 'latin1',
'collate' => 'latin1_general_ci'
)
),
);
$compare = $this->Schema->compare($old, $new);
$expected = array(
'posts' => array(
'change' => array(
'title' => array(
'type' => 'datetime',
'null' => false,
)
)
),
);
$this->assertEquals($expected, $compare, 'Invalid SQL, datetime does not have length');
}
/**
* testSchemaLoading method
*