Skip to content

Commit

Permalink
Changing break; to continue; so it will process the next tables on th…
Browse files Browse the repository at this point in the history
…e array, tests added.
  • Loading branch information
renan committed May 29, 2010
1 parent 2d44929 commit 8f5112b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/model/cake_schema.php
Expand Up @@ -451,7 +451,7 @@ function compare($old, $new = null) {
$tables = array();
foreach ($new as $table => $fields) {
if ($table == 'missing') {
break;
continue;
}
if (!array_key_exists($table, $old)) {
$tables[$table]['add'] = $fields;
Expand Down
39 changes: 39 additions & 0 deletions cake/tests/cases/libs/model/cake_schema.test.php
Expand Up @@ -743,6 +743,45 @@ function testSchemaComparison() {
),
);
$this->assertEqual($expected, $compare);

$tables = array(
'missing' => array(
'categories' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'name' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 100),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
),
'ratings' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
);
$compare = $New->compare($this->Schema, $tables);
$expected = array(
'ratings' => array(
'add' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
)
);
$this->assertEqual($expected, $compare);
}

/**
Expand Down

0 comments on commit 8f5112b

Please sign in to comment.