Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changing break; to continue; so it will process the next tables on th…

…e array, tests added.
  • Loading branch information...
commit 40cfd5cb1d4b34e7367b0b56ab38014458abc13d 1 parent 4ebeeef
@renan renan authored
View
2  cake/libs/model/schema.php
@@ -392,7 +392,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;
View
36 cake/tests/cases/libs/model/schema.test.php
@@ -457,6 +457,42 @@ 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))
+ )
+ ),
+ '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))
+ )
+ );
+ $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))
+ )
+ )
+ );
+ $this->assertEqual($expected, $compare);
}
/**
* testSchemaLoading method
Please sign in to comment.
Something went wrong with that request. Please try again.