diff --git a/build.xml b/build.xml index af2a1e288..d36dbb381 100644 --- a/build.xml +++ b/build.xml @@ -29,6 +29,7 @@ + @@ -140,7 +137,6 @@ script - php php php php @@ -244,11 +240,11 @@ - + - + diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index a306bd51f..22e41d9a5 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -110,6 +110,7 @@ class ControllerTask extends BakeTask { $admin = $this->Project->getPrefix(); } + $controllersCreated = 0; foreach ($this->__tables as $table) { $model = $this->_modelName($table); $controller = $this->_controllerName($model); @@ -123,8 +124,13 @@ class ControllerTask extends BakeTask { if ($this->bake($controller, $actions) && $unitTestExists) { $this->bakeTest($controller); } + $controllersCreated++; } } + + if (!$controllersCreated) { + $this->out(__d('cake_console', 'No Controllers were baked, Models need to exist before Controllers can be baked.')); + } } /** diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 4adfced39..9eceb725a 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -305,7 +305,7 @@ class TranslateBehavior extends ModelBehavior { } } else { $value = ''; - if (!empty($row[$Model->alias][$aliasVirtual])) { + if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) { $value = $row[$Model->alias][$aliasVirtual]; } $row[$Model->alias][$aliasField] = $value; diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index fe18575b8..44eba0881 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -354,6 +354,31 @@ class TranslateBehaviorTest extends CakeTestCase { $this->assertEquals($expected, $result); } +/** + * Test loading fields with 0 as the translated value. + */ + public function testFetchTranslationsWithZero() { + $this->loadFixtures('Translate', 'TranslatedItem'); + + $model = new TranslatedItem(); + $translateModel = $model->translateModel(); + $translateModel->updateAll(array('content' => "'0'")); + $model->locale = 'eng'; + + $result = $model->read(null, 1); + $expected = array( + 'TranslatedItem' => array( + 'id' => 1, + 'slug' => 'first_translated', + 'locale' => 'eng', + 'title' => '0', + 'content' => '0', + 'translated_article_id' => 1, + ) + ); + $this->assertEquals($expected, $result); + } + /** * testLocaleMultiple method * diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index 4c791a5d5..3488d6a92 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -65,7 +65,7 @@ class CakeTestFixtureTestFixture extends CakeTestFixture { } /** - * StringFieldsTestFixture class + * StringTestFixture class * * @package Cake.Test.Case.TestSuite */ @@ -109,6 +109,50 @@ class StringsTestFixture extends CakeTestFixture { ); } +/** + * InvalidTestFixture class + * + * @package Cake.Test.Case.TestSuite + */ +class InvalidTestFixture extends CakeTestFixture { + +/** + * Name property + * + * @var string + */ + public $name = 'Invalid'; + +/** + * Table property + * + * @var string + */ + public $table = 'invalid'; + +/** + * Fields array - missing "email" row + * + * @var array + */ + public $fields = array( + 'id' => array('type' => 'integer', 'key' => 'primary'), + 'name' => array('type' => 'string', 'length' => '255'), + 'age' => array('type' => 'integer', 'default' => 10) + ); + +/** + * Records property + * + * @var array + */ + public $records = array( + array('name' => 'Mark Doe', 'email' => 'mark.doe@email.com'), + array('name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20), + array('email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30) + ); +} + /** * CakeTestFixtureImportFixture class * @@ -482,6 +526,17 @@ class CakeTestFixtureTest extends CakeTestCase { $this->assertEquals($expected, $this->insertMulti['fields_values']); } +/** + * test the insert method with invalid fixture + * + * @expectedException CakeException + * @return void + */ + public function testInsertInvalid() { + $Fixture = new InvalidTestFixture(); + $return = $Fixture->insert($this->criticDb); + } + /** * Test the drop method * diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index f667ba81c..aaf4ae780 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -6315,6 +6315,25 @@ class FormHelperTest extends CakeTestCase { $this->assertNotRegExp('/selected="selected">\d/', $result); } +/** + * testDateTime all zeros + * + * @return void + */ + public function testDateTimeAllZeros() { + $result = $this->Form->dateTime('Contact.date', + 'DMY', + false, + array( + 'empty' => array('day' => '-', 'month' => '-', 'year' => '-'), + 'value' => '0000-00-00' + ) + ); + + $this->assertRegExp('/