mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Testcase added, refs #2672
This commit is contained in:
parent
5033fb60d6
commit
a2fb4178fb
1 changed files with 50 additions and 2 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue