From 8f5112b8d73709ef3e55c4c1b7988109bb1ae54e Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Sat, 29 May 2010 12:06:36 -0300 Subject: [PATCH] Changing break; to continue; so it will process the next tables on the array, tests added. --- cake/libs/model/cake_schema.php | 2 +- .../cases/libs/model/cake_schema.test.php | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index adee3df01..7901cdf09 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -451,7 +451,7 @@ class CakeSchema extends Object { $tables = array(); foreach ($new as $table => $fields) { if ($table == 'missing') { - break; + continue; } if (!array_key_exists($table, $old)) { $tables[$table]['add'] = $fields; diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 664364e3d..c07b9d998 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -743,6 +743,45 @@ class CakeSchemaTest extends CakeTestCase { ), ); $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); } /**