Skip to content

Commit

Permalink
Testcase added, refs #2672
Browse files Browse the repository at this point in the history
  • Loading branch information
ceeram authored and markstory committed Mar 13, 2012
1 parent 5033fb6 commit a2fb417
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions lib/Cake/Test/Case/Model/CakeSchemaTest.php
Expand Up @@ -642,11 +642,11 @@ public function testSchemaReadWithTablePrefix() {
*/
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));
Expand Down Expand Up @@ -964,6 +964,54 @@ public function testTableParametersAndIndexComparison() {
$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
*
Expand Down

0 comments on commit a2fb417

Please sign in to comment.