mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating tests for schema. Making tests more reliable for schema read.
This commit is contained in:
parent
e733c569be
commit
236a679b17
2 changed files with 22 additions and 9 deletions
|
@ -368,7 +368,7 @@ class CakeSchema extends Object {
|
||||||
$out .= $this->generateTable($table, $fields);
|
$out .= $this->generateTable($table, $fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .="}\n";
|
$out .= "}\n";
|
||||||
|
|
||||||
$File =& new File($path . DS . $file, true);
|
$File =& new File($path . DS . $file, true);
|
||||||
$header = '$Id';
|
$header = '$Id';
|
||||||
|
@ -430,7 +430,7 @@ class CakeSchema extends Object {
|
||||||
*/
|
*/
|
||||||
function compare($old, $new = null) {
|
function compare($old, $new = null) {
|
||||||
if (empty($new)) {
|
if (empty($new)) {
|
||||||
$new = $this;
|
$new =& $this;
|
||||||
}
|
}
|
||||||
if (is_array($new)) {
|
if (is_array($new)) {
|
||||||
if (isset($new['tables'])) {
|
if (isset($new['tables'])) {
|
||||||
|
@ -467,7 +467,7 @@ class CakeSchema extends Object {
|
||||||
foreach ($fields as $field => $value) {
|
foreach ($fields as $field => $value) {
|
||||||
if (isset($old[$table][$field])) {
|
if (isset($old[$table][$field])) {
|
||||||
$diff = array_diff_assoc($value, $old[$table][$field]);
|
$diff = array_diff_assoc($value, $old[$table][$field]);
|
||||||
if (!empty($diff) && $field !== 'indexes') {
|
if (!empty($diff) && $field !== 'indexes' && $field !== 'tableParameters') {
|
||||||
$tables[$table]['change'][$field] = array_merge($old[$table][$field], $diff);
|
$tables[$table]['change'][$field] = array_merge($old[$table][$field], $diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,6 +489,9 @@ class CakeSchema extends Object {
|
||||||
$tables[$table]['add']['indexes'] = $diff['add'];
|
$tables[$table]['add']['indexes'] = $diff['add'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($old[$table]['tableParameters']) && isset($new[$table]['tableParameters'])) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ class TestAppSchema extends CakeSchema {
|
||||||
*/
|
*/
|
||||||
var $datatypes = array(
|
var $datatypes = array(
|
||||||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
|
'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'),
|
||||||
'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2'),
|
'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => ''),
|
||||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
||||||
'tableParameters' => array()
|
'tableParameters' => array()
|
||||||
);
|
);
|
||||||
|
@ -389,7 +389,9 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $fixtures = array('core.post', 'core.tag', 'core.posts_tag', 'core.comment', 'core.datatype');
|
var $fixtures = array(
|
||||||
|
'core.post', 'core.tag', 'core.posts_tag', 'core.comment', 'core.datatype', 'core.auth_user'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* setUp method
|
||||||
|
@ -450,7 +452,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
$this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table]));
|
$this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertIdentical(
|
$this->assertEqual(
|
||||||
$read['tables']['datatypes']['float_field'],
|
$read['tables']['datatypes']['float_field'],
|
||||||
$this->Schema->tables['datatypes']['float_field']
|
$this->Schema->tables['datatypes']['float_field']
|
||||||
);
|
);
|
||||||
|
@ -468,7 +470,7 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function XXtestSchemaReadWithPlugins() {
|
function testSchemaReadWithPlugins() {
|
||||||
App::objects('model', null, false);
|
App::objects('model', null, false);
|
||||||
App::build(array(
|
App::build(array(
|
||||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||||
|
@ -480,7 +482,11 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
'name' => 'TestApp',
|
'name' => 'TestApp',
|
||||||
'models' => true
|
'models' => true
|
||||||
));
|
));
|
||||||
|
unset($read['tables']['missing']);
|
||||||
$this->assertTrue(isset($read['tables']['posts']));
|
$this->assertTrue(isset($read['tables']['posts']));
|
||||||
|
$this->assertTrue(isset($read['tables']['auth_users']));
|
||||||
|
$this->assertEqual(count($read['tables']), 2);
|
||||||
|
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
@ -538,13 +544,17 @@ class CakeSchemaTest extends CakeTestCase {
|
||||||
'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||||||
'title' => array('type' => 'string', 'null' => false, 'length' => 100)
|
'title' => array('type' => 'string', 'null' => false, 'length' => 100)
|
||||||
),
|
),
|
||||||
'drop' => array('article_id' => array('type' => 'integer', 'null' => false)),
|
'drop' => array(
|
||||||
|
'article_id' => array('type' => 'integer', 'null' => false),
|
||||||
|
'tableParameters' => array()
|
||||||
|
),
|
||||||
'change' => array(
|
'change' => array(
|
||||||
'comment' => array('type' => 'text', 'null' => false, 'default' => null)
|
'comment' => array('type' => 'text', 'null' => false, 'default' => null)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'posts' => array(
|
'posts' => array(
|
||||||
'add' => array('summary' => array('type' => 'text', 'null' => 1)),
|
'add' => array('summary' => array('type' => 'text', 'null' => 1)),
|
||||||
|
'drop' => array('tableParameters' => array()),
|
||||||
'change' => array(
|
'change' => array(
|
||||||
'author_id' => array('type' => 'integer', 'null' => true, 'default' => ''),
|
'author_id' => array('type' => 'integer', 'null' => true, 'default' => ''),
|
||||||
'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'),
|
'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'),
|
||||||
|
|
Loading…
Reference in a new issue