From 2abf34d93e26894436bf1b198e74936d47e7a541 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 16 Aug 2010 22:11:25 -0400 Subject: [PATCH 01/24] Fixing issue where an app that was in a directory that had the same name as a controller would end up failing to find view cache files. Adding test for app name in controller name failure to create cache Fixes #1025 Conflicts: cake/libs/view/helpers/cache.php --- .../cases/libs/view/helpers/cache.test.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 23e47f936..3a42ec0fa 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -451,6 +451,43 @@ class CacheHelperTest extends CakeTestCase { $this->assertTrue(file_exists($filename)); @unlink($filename); } + +/** + * test ControllerName contains AppName + * + * This test verifys view cache is created correctly when the app name is contained in part of the controller name. + * (webapp Name) base name is 'cache' controller is 'cacheTest' action is 'cache_name' + * apps url would look somehing like http://localhost/cache/cacheTest/cache_name + * + * @return void + **/ + function testCacheBaseNameControllerName() { + $this->Controller->cache_parsing(); + $this->Controller->cacheAction = array( + 'cache_name' => 21600 + ); + $this->Controller->params = array( + 'controller' => 'cacheTest', + 'action' => 'cache_name', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); + $this->Controller->here = '/cache/cacheTest/cache_name'; + $this->Controller->action = 'cache_name'; + $this->Controller->base = '/cache'; + + $View = new View($this->Controller); + $result = $View->render('index'); + + $this->assertNoPattern('/cake:nocache/', $result); + $this->assertNoPattern('/php echo/', $result); + + $filename = CACHE . 'views' . DS . 'cache_cachetest_cache_name.php'; + $this->assertTrue(file_exists($filename)); + @unlink($filename); + } + /** * testCacheEmptySections method * From fc9340213e2907fe22625dbe9e356ecb5745866d Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 16 Aug 2010 22:25:55 -0400 Subject: [PATCH 02/24] Applying patch from 'thatcode', makes the 'us' rule case insensitive. Fixes #1020 --- cake/libs/inflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 9cae3a1d2..65563639f 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -56,7 +56,7 @@ class Inflector { '/(c)hild$/i' => '\1hildren', '/(buffal|tomat)o$/i' => '\1\2oes', '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i', - '/us$/' => 'uses', + '/us$/i' => 'uses', '/(alias)$/i' => '\1es', '/(ax|cris|test)is$/i' => '\1es', '/s$/' => 's', From b22f2f746bc3b38fa46e6d1ca68116baacc119e6 Mon Sep 17 00:00:00 2001 From: zimakm Date: Wed, 18 Aug 2010 03:27:08 -0700 Subject: [PATCH 03/24] Configure fix problem 3-dimensional arrays to be handled as 4+ arrays. This saves a lot of execution time when configure holds many values. Fixes #1028 Signed-off-by: mark_story --- cake/libs/configure.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index fc2f4eeda..79dff7bd0 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -96,6 +96,7 @@ class Configure extends Object { break; case 3: $_this->{$names[0]}[$names[1]][$names[2]] = $value; + break; case 4: $names = explode('.', $name, 2); if (!isset($_this->{$names[0]})) { From e23fe25787cfc53d6d8d5aa28d6c0af4873bf797 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 00:17:40 -0400 Subject: [PATCH 04/24] Fixing code formatting. --- cake/libs/configure.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 79dff7bd0..1428ba896 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -96,7 +96,7 @@ class Configure extends Object { break; case 3: $_this->{$names[0]}[$names[1]][$names[2]] = $value; - break; + break; case 4: $names = explode('.', $name, 2); if (!isset($_this->{$names[0]})) { From afc05c1e050869b20e85be87ac3d378c146b9a52 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 00:19:30 -0400 Subject: [PATCH 05/24] Adding test cases for using localized floats with mysql. Also added a generic model test case. Refs #1029 --- .../model/datasources/dbo/dbo_mysql.test.php | 18 ++++++++++++++++++ .../cases/libs/model/model_write.test.php | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 5a1bb4619..59298f134 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -277,6 +277,24 @@ class DboMysqlTest extends CakeTestCase { $this->assertEqual($expected, $result); } +/** + * test that localized floats don't cause trouble. + * + * @return void + */ + function testLocalizedFloats() { + $restore = setlocale(LC_ALL, null); + setlocale(LC_ALL, 'de_DE'); + + $result = $this->db->value(3.141593, 'float'); + $this->assertEqual((string)$result, '3.141593'); + + $result = $this->db->value(3.141593); + $this->assertEqual((string)$result, '3.141593'); + + setlocale(LC_ALL, $restore); + } + /** * testTinyintCasting method * diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 9c01485d5..7de1d0820 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -3880,4 +3880,22 @@ class ModelWriteTest extends BaseModelTest { $this->assertFalse($result); } +/** + * test writing floats in german locale. + * + * @return void + */ + function testWriteFloatAsGerman() { + $restore = setlocale(LC_ALL, null); + setlocale(LC_ALL, 'de_DE'); + + $model = new DataTest(); + $result = $model->save(array( + 'count' => 1, + 'float' => 3.14593 + )); + $this->assertTrue($result); + setlocale(LC_ALL, $restore); + } + } From eb96d8acfbe6c31230fb28f21110aaec5de57eaf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 00:39:45 -0400 Subject: [PATCH 06/24] Adding tests to dbo_postgres for localized floats. Refs #1029 --- .../datasources/dbo/dbo_postgres.test.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index ad7b3166b..3fd70d1db 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -352,7 +352,7 @@ class DboPostgresTest extends CakeTestCase { * @return void */ function testValueQuoting() { - $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.2'"); + $this->assertIdentical($this->db2->value(1.2, 'float'), "'1.200000'"); $this->assertEqual($this->db2->value('1,2', 'float'), "'1,2'"); $this->assertEqual($this->db2->value('0', 'integer'), "'0'"); @@ -378,6 +378,24 @@ class DboPostgresTest extends CakeTestCase { $this->assertEqual($this->db2->value(array()), "NULL"); } +/** + * test that localized floats don't cause trouble. + * + * @return void + */ + function testLocalizedFloats() { + $restore = setlocale(LC_ALL, null); + setlocale(LC_ALL, 'de_DE'); + + $result = $this->db->value(3.141593, 'float'); + $this->assertEqual((string)$result, "'3.141593'"); + + $result = $this->db->value(3.14); + $this->assertEqual((string)$result, "'3.140000'"); + + setlocale(LC_ALL, $restore); + } + /** * test that date and time columns do not generate errors with null and nullish values. * From 12d4b52f105e6c84824eb5c8e6ca6d4996760e4d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 00:49:40 -0400 Subject: [PATCH 07/24] Fixing failing tests in DboMysql and DboPostgres related to localized floats. Refs #1029 --- cake/libs/model/datasources/dbo/dbo_mysql.php | 15 +++++++++------ cake/libs/model/datasources/dbo/dbo_postgres.php | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 7b0bfea9b..1ed2ae13a 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -658,16 +658,19 @@ class DboMysql extends DboMysqlBase { if ($data === '') { return 'NULL'; } - if ((is_int($data) || is_float($data) || $data === '0') || ( + if (is_float($data)) { + return sprintf('%F', $data); + } + if ((is_int($data) || $data === '0') || ( is_numeric($data) && strpos($data, ',') === false && - $data[0] != '0' && strpos($data, 'e') === false)) { - return $data; - } + $data[0] != '0' && strpos($data, 'e') === false) + ) { + return $data; + } default: - $data = "'" . mysql_real_escape_string($data, $this->connection) . "'"; + return "'" . mysql_real_escape_string($data, $this->connection) . "'"; break; } - return $data; } /** diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 6c692d942..bd4e8562b 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -299,8 +299,11 @@ class DboPostgres extends DboSource { } switch($column) { - case 'inet': case 'float': + if (is_float($data)) { + $data = sprintf('%F', $data); + } + case 'inet': case 'integer': case 'date': case 'datetime': From 5446a062ee444c6973c76a4562eb3afe2f46d967 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 21 Aug 2010 22:48:59 -0400 Subject: [PATCH 08/24] Fixing issue where whitelist would not be used for validation. Test case added. Fixes #1037 --- cake/libs/model/model.php | 2 +- .../libs/model/model_validation.test.php | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index f99f75c7c..100d331b5 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2511,7 +2511,7 @@ class Model extends Overloadable { $_validate = $this->validate; $whitelist = $this->whitelist; - if (array_key_exists('fieldList', $options)) { + if (!empty($options['fieldList'])) { $whitelist = $options['fieldList']; } diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/cake/tests/cases/libs/model/model_validation.test.php index 6da40853d..bbf00996e 100644 --- a/cake/tests/cases/libs/model/model_validation.test.php +++ b/cake/tests/cases/libs/model/model_validation.test.php @@ -164,11 +164,34 @@ class ModelValidationTest extends BaseModelTest { $TestModel->invalidFields(); $expected = array('name' => 'This field cannot be left blank'); $this->assertEqual($TestModel->validationErrors, $expected); - $TestModel->validationErrors = array(); $this->assertEqual($TestModel->validate, $validate); } +/** + * Test that invalidFields() integrates well with save(). And that fieldList can be an empty type. + * + * @return void + */ + function testInvalidFieldsWhitelist() { + $TestModel =& new ValidationTest1(); + $TestModel->validate = $validate = array( + 'title' => array( + 'rule' => 'customValidator', + 'required' => true + ), + 'name' => array( + 'rule' => 'alphaNumeric', + 'required' => true + )); + + $TestModel->whitelist = array('name'); + $TestModel->save(array('name' => '#$$#')); + + $expected = array('name' => 'This field cannot be left blank'); + $this->assertEqual($TestModel->validationErrors, $expected); + } + /** * testValidates method * From ece055eefe3fb374505f618a9d1c8d2c9b9a448d Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 23 Aug 2010 21:39:23 -0400 Subject: [PATCH 09/24] Adding object type check to prevent fatal errors caused by view being used like a model object. Tests added. Fixes #1039 --- cake/libs/view/helper.php | 6 +++++- cake/tests/cases/libs/view/helper.test.php | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 570cd691c..ecd731b90 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -442,7 +442,11 @@ class Helper extends Overloadable { if (ClassRegistry::isKeySet($model)) { $ModelObj =& ClassRegistry::getObject($model); for ($i = 0; $i < $count; $i++) { - if ($ModelObj->hasField($parts[$i]) || array_key_exists($parts[$i], $ModelObj->validate)) { + if ( + is_a($ModelObj, 'Model') && + ($ModelObj->hasField($parts[$i]) || + array_key_exists($parts[$i], $ModelObj->validate)) + ) { $hasField = $i; if ($hasField === 0 || ($hasField === 1 && is_numeric($parts[0]))) { $sameScope = true; diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 311e1b9b8..6f81c455e 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -219,7 +219,7 @@ class HelperTest extends CakeTestCase { * @access public * @return void */ - function testFormFieldNameParsing() { + function testSetEntity() { // PHP4 reference hack ClassRegistry::removeObject('view'); ClassRegistry::addObject('view', $this->View); @@ -350,6 +350,17 @@ class HelperTest extends CakeTestCase { $this->assertEqual($this->View->fieldSuffix, null); } +/** + * test that 'view' doesn't break things. + * + * @return void + */ + function testSetEntityWithView() { + $this->assertNull($this->Helper->setEntity('Allow.view.group_id')); + $this->assertNull($this->Helper->setEntity('Allow.view')); + $this->assertNull($this->Helper->setEntity('View.view')); + } + /** * test getting values from Helper * From c48c0d62950d28e0c0cb01cfb25bef3b21cc0529 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 23 Aug 2010 21:49:30 -0400 Subject: [PATCH 10/24] Fixing issue where ViewTask would make empty view files for actions that did not have templates. Test case added. Fixes #1040 --- cake/console/libs/tasks/view.php | 3 +++ cake/tests/cases/console/libs/tasks/view.test.php | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 2ebffc733..7ccc74072 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -366,6 +366,9 @@ class ViewTask extends BakeTask { if ($content === true) { $content = $this->getContent($action); } + if (empty($content)) { + return false; + } $path = $this->getPath(); $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; return $this->createFile($filename, $content); diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php index 12f9d79d7..405b00a9a 100644 --- a/cake/tests/cases/console/libs/tasks/view.test.php +++ b/cake/tests/cases/console/libs/tasks/view.test.php @@ -374,6 +374,19 @@ class ViewTaskTest extends CakeTestCase { $this->Task->bake('index', true); } +/** + * test that baking a view with no template doesn't make a file. + * + * @return void + */ + function testBakeWithNoTemplate() { + $this->Task->controllerName = 'ViewTaskComments'; + $this->Task->controllerPath = 'view_task_comments'; + + $this->Task->expectNever('createFile'); + $this->Task->bake('delete', true); + } + /** * test bake() with a -plugin param * From 903b26063821dbdafd3c381cb121c78a42bc4a80 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Aug 2010 20:29:03 -0400 Subject: [PATCH 11/24] Changing spaces to tabs. --- cake/tests/cases/libs/view/helpers/text.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php index 7a5470c01..316c61c7a 100644 --- a/cake/tests/cases/libs/view/helpers/text.test.php +++ b/cake/tests/cases/libs/view/helpers/text.test.php @@ -399,13 +399,13 @@ class TextHelperTest extends CakeTestCase { $result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y'); $this->assertEqual($result, 'Dusty, Lucky y Ned'); - $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y'); - $this->assertEqual($result, 'Dusty, Lucky y Ned'); + $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y'); + $this->assertEqual($result, 'Dusty, Lucky y Ned'); - $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'and', ' + '); - $this->assertEqual($result, 'Dusty + Lucky and Ned'); + $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'and', ' + '); + $this->assertEqual($result, 'Dusty + Lucky and Ned'); - $result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky')); - $this->assertEqual($result, 'Dusty and Lucky'); + $result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky')); + $this->assertEqual($result, 'Dusty and Lucky'); } } From 465c24f90313299a3bfa1b8ffb22f710ba021b5b Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Aug 2010 20:30:30 -0400 Subject: [PATCH 12/24] Adding a test case for TextHelper::toList(). Closes #1043 --- cake/tests/cases/libs/view/helpers/text.test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/cake/tests/cases/libs/view/helpers/text.test.php index 316c61c7a..f4c18d628 100644 --- a/cake/tests/cases/libs/view/helpers/text.test.php +++ b/cake/tests/cases/libs/view/helpers/text.test.php @@ -407,5 +407,8 @@ class TextHelperTest extends CakeTestCase { $result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky')); $this->assertEqual($result, 'Dusty and Lucky'); + + $result = $this->Text->toList(array( 'test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon')); + $this->assertEqual($result, 'banana, apple and lemon'); } } From 95168cee6e4a75f85ed414e7be48c93eb9d49929 Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Tue, 24 Aug 2010 12:14:46 +0100 Subject: [PATCH 13/24] casting the find as an array to avoid errors with array_values() fixes #1041 and 4 failing tests (3 previous) Signed-off-by: mark_story --- cake/libs/model/behaviors/tree.php | 2 +- cake/tests/cases/libs/model/behaviors/tree.test.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 10bd8544b..349506213 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -284,7 +284,7 @@ class TreeBehavior extends ModelBehavior { if (!$id) { $conditions = $scope; } else { - $result = array_values($Model->find('first', array( + $result = array_values((array)$Model->find('first', array( 'conditions' => array($scope, $Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php index c0dc9ccc0..39475cd60 100644 --- a/cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/cake/tests/cases/libs/model/behaviors/tree.test.php @@ -1089,6 +1089,8 @@ class NumberTreeTest extends CakeTestCase { array($modelClass => array( 'id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)), array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12))); $this->assertEqual($total, $expects); + + $this->assertEqual(array(), $this->Tree->children(10000)); } /** From 123873b4d817aacc9b7e7764fa04c73122ef486e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Aug 2010 21:20:13 -0400 Subject: [PATCH 14/24] Updating DboSource test to account for formatting of floats done in mysql/postgresql. --- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 6a71591bd..442d690ac 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -2548,11 +2548,11 @@ class DboSourceTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = $this->testDb->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7))); - $expected = " WHERE `score` BETWEEN 90.1 AND 95.7"; + $expected = " WHERE `score` BETWEEN 90.100000 AND 95.700000"; $this->assertEqual($result, $expected); $result = $this->testDb->conditions(array('Post.title' => 1.1)); - $expected = " WHERE `Post`.`title` = 1.1"; + $expected = " WHERE `Post`.`title` = 1.100000"; $this->assertEqual($result, $expected); $result = $this->testDb->conditions(array('Post.title' => 1.1), true, true, new Post()); From ea9e30890fa80558fc8afb005cc22231c0e1d1db Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Aug 2010 21:24:09 -0400 Subject: [PATCH 15/24] Adding a workaround to DboSource::showLog() to work around fix added in [da9c0da626901a1462e63af7e6840693bcb1f1d2]. Also adding explanation message when logs are not generated. --- cake/libs/model/datasources/dbo_source.php | 2 +- cake/libs/view/elements/sql_dump.ctp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 940a909df..abe268294 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -630,7 +630,7 @@ class DboSource extends DataSource { $controller = null; $View =& new View($controller, false); $View->set('logs', array($this->configKeyName => $log)); - echo $View->element('sql_dump'); + echo $View->element('sql_dump', array('_forced_from_dbo_' => true)); } else { foreach ($log['log'] as $k => $i) { print (($k + 1) . ". {$i['query']} {$i['error']}\n"); diff --git a/cake/libs/view/elements/sql_dump.ctp b/cake/libs/view/elements/sql_dump.ctp index c5cea554c..283946deb 100644 --- a/cake/libs/view/elements/sql_dump.ctp +++ b/cake/libs/view/elements/sql_dump.ctp @@ -20,7 +20,8 @@ if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) { return false; } -if (!isset($logs)): +$noLogs = !isset($logs); +if ($noLogs): $sources = ConnectionManager::sourceList(); $logs = array(); @@ -31,8 +32,9 @@ if (!isset($logs)): endif; $logs[$source] = $db->getLog(); endforeach; +endif; - +if ($noLogs || isset($_forced_from_dbo_)): foreach ($logs as $source => $logInfo): $text = $logInfo['count'] > 1 ? 'queries' : 'query'; printf( @@ -52,6 +54,8 @@ if (!isset($logs)): ?> Encountered unexpected $logs cannot generate SQL log

'; endif; ?> From b02e21395834a59f7df5848a1f352f39da696c4c Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 26 Aug 2010 22:21:39 -0400 Subject: [PATCH 16/24] Adding test case from '0x20h'. Fixing issue where atomic = false, validate = first and saveAll() saving many rows could return an incorrect value. Fixes #1050 --- cake/libs/model/model.php | 2 +- .../cases/libs/model/model_write.test.php | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 100d331b5..32a19a717 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1593,6 +1593,7 @@ class Model extends Overloadable { if (Set::numeric(array_keys($data))) { while ($validates) { + $return = array(); foreach ($data as $key => $record) { if (!$currentValidates = $this->__save($record, $options)) { $validationErrors[$key] = $this->validationErrors; @@ -1624,7 +1625,6 @@ class Model extends Overloadable { break; case ($options['validate'] === 'first'): $options['validate'] = true; - $return = array(); break; default: if ($options['atomic']) { diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 7de1d0820..497bc56fa 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -3584,6 +3584,65 @@ class ModelWriteTest extends BaseModelTest { $this->assertEqual($result[0]['Comment'][0]['comment'], 'Only new comment'); } +/** + * test saveAll()'s return is correct when using atomic = false and validate = first. + * + * @return void + */ + function testSaveAllValidateFirstAtomicFalse() { + $Something =& new Something(); + $invalidData = array( + array( + 'title' => 'foo', + 'body' => 'bar', + 'published' => 'baz', + ), + array( + 'body' => 3, + 'published' =>'sd', + ), + ); + $Something->create(); + $Something->validate = array( + 'title' => array( + 'rule' => 'alphaNumeric', + 'required' => true, + ), + 'body' => array( + 'rule' => 'alphaNumeric', + 'required' => true, + 'allowEmpty' => true, + ), + ); + $result = $Something->saveAll($invalidData, array( + 'atomic' => false, + 'validate' => 'first', + )); + $expected = array(true, false); + $this->assertEqual($result, $expected); + + $Something =& new Something(); + $validData = array( + array( + 'title' => 'title value', + 'body' => 'body value', + 'published' => 'baz', + ), + array( + 'title' => 'valid', + 'body' => 'this body', + 'published' =>'sd', + ), + ); + $Something->create(); + $result = $Something->saveAll($validData, array( + 'atomic' => false, + 'validate' => 'first', + )); + $expected = array(true, true); + $this->assertEqual($result, $expected); + } + /** * testUpdateWithCalculation method * From 08d6c19ab6aa65f68226d7dafd0a3ab27bd7ea26 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 31 Aug 2010 21:21:05 -0400 Subject: [PATCH 17/24] Adding test for themes in app/webroot dir. Closes #1061 --- .../cases/libs/view/helpers/html.test.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 5b98a6d33..05bd540db 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -626,6 +626,34 @@ class HtmlHelperTest extends CakeTestCase { $this->assertNull($result); } +/** + * test a script file in the webroot/theme dir. + * + * @return void + */ + function testScriptInTheme() { + if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) { + return; + } + App::import('Core', 'File'); + + $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; + $file =& new File($testfile, true); + + App::build(array( + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) + )); + + $this->Html->webroot = '/'; + $this->Html->theme = 'test_theme'; + $result = $this->Html->script('__test_js.js'); + $expected = array( + 'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript') + ); + $this->assertTags($result, $expected); + App::build(); + } + /** * test Script block generation * From 3e5e52d52e5775d8836342a4623b0dc1a6ca3fda Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 2 Sep 2010 00:29:04 -0400 Subject: [PATCH 18/24] Fixing doc block for Form::create(). Fixes #1058 --- cake/libs/view/helpers/form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 29dc58116..3a9c60815 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -172,7 +172,7 @@ class FormHelper extends AppHelper { * ### Options: * * - `type` Form method defaults to POST - * - `action` The Action the form submits to. Can be a string or array, + * - `action` The controller action the form submits to, (optional). * - `url` The url the form submits to. Can be a string or a url array, * - `default` Allows for the creation of Ajax forms. * - `onsubmit` Used in conjunction with 'default' to create ajax forms. From dbdd17f51ad26e27cae5c61e6938284f5f1a6267 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Thu, 2 Sep 2010 11:16:10 -0400 Subject: [PATCH 19/24] Adding test cases from 'euromark' and updating how email addresses are parsed so they are slightly more conformant to RFC 5322. Fixes #1066 --- cake/libs/controller/components/email.php | 13 ++++----- .../libs/controller/components/email.test.php | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index aae446593..53d642b0f 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -743,19 +743,16 @@ class EmailComponent extends Object{ * @access private */ function _formatAddress($string, $smtp = false) { - if (strpos($string, '<') !== false) { - $value = explode('<', $string); - if ($smtp) { - $string = '<' . $value[1]; - } else { - $string = $this->_encode($value[0]) . ' <' . $value[1]; - } + $hasAlias = preg_match('/(.+)\s<(.+)>/', $string, $matches); + if ($hasAlias) { + return $this->_strip($matches[1] . ' <' . $matches[2] . '>'); } return $this->_strip($string); } /** - * Remove certain elements (such as bcc:, to:, %0a) from given value + * Remove certain elements (such as bcc:, to:, %0a) from given value. + * Helps prevent header injection / mainipulation on user content. * * @param string $value Value to strip * @param boolean $message Set to true to indicate main message content diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 6d19c77f0..4684d88df 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -128,6 +128,15 @@ class EmailTestComponent extends EmailComponent { function strip($content, $message = false) { return parent::_strip($content, $message); } + +/** + * Wrapper for testing. + * + * @return void + */ + function formatAddress($string, $smtp = false) { + return parent::_formatAddress($string, $smtp); + } } /** @@ -1151,4 +1160,23 @@ HTMLBLOC; ); $this->assertEqual($expected, $result); } + +/** + * Test that _formatName doesn't jack up email addresses with alias parts. + * + * @return void + */ + function testFormatAddressAliases() { + $result = $this->Controller->EmailTest->formatAddress('email@example.com'); + $this->assertEqual($result, 'email@example.com'); + + $result = $this->Controller->EmailTest->formatAddress('alias '); + $this->assertEqual($result, 'alias '); + + $result = $this->Controller->EmailTest->formatAddress('email@example.com'); + $this->assertEqual($result, 'email@example.com'); + + $result = $this->Controller->EmailTest->formatAddress(''); + $this->assertEqual($result, ''); + } } From 5c0fe1b16e1635d7a3bdf60b43c90aae20665060 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 3 Sep 2010 12:33:59 -0400 Subject: [PATCH 20/24] Applying patch from 'majna'. Adding plugin to the list of template variables exposed in the controller task. Test added Fixes #1077 --- cake/console/libs/tasks/controller.php | 7 ++++--- cake/tests/cases/console/libs/tasks/controller.test.php | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index 36fd91600..b7f04bb18 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -275,8 +275,9 @@ class ControllerTask extends BakeTask { */ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) { $currentModelName = $modelImport = $this->_modelName($controllerName); - if ($this->plugin) { - $modelImport = $this->plugin . '.' . $modelImport; + $plugin = $this->plugin; + if ($plugin) { + $modelImport = $plugin . '.' . $modelImport; } if (!App::import('Model', $modelImport)) { $this->err(__('You must have a model for this class to build basic methods. Please try again.', true)); @@ -290,7 +291,7 @@ class ControllerTask extends BakeTask { $singularHumanName = $this->_singularHumanName($controllerName); $pluralHumanName = $this->_pluralName($controllerName); - $this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', + $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName')); $actions = $this->Template->generate('actions', 'controller_actions'); return $actions; diff --git a/cake/tests/cases/console/libs/tasks/controller.test.php b/cake/tests/cases/console/libs/tasks/controller.test.php index 0fbc888ff..618b0dfd3 100644 --- a/cake/tests/cases/console/libs/tasks/controller.test.php +++ b/cake/tests/cases/console/libs/tasks/controller.test.php @@ -299,6 +299,8 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expectAt(1, 'createFile', array( $path, new PatternExpectation('/ArticlesController extends ControllerTestAppController/'))); $this->Task->bake('Articles', '--actions--', array(), array(), array()); + + $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); } /** From 82fffe6914429ad8b2cc8b1ee4cc34b657e574f5 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 5 Sep 2010 01:28:13 -0400 Subject: [PATCH 21/24] Fixing issue where FormHelper::select() with multiple = checkbox and a custom name attribute would not work correctly. Fixes #1078 --- cake/libs/view/helpers/form.php | 7 +-- .../cases/libs/view/helpers/form.test.php | 52 +++++++++++++++++-- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 3a9c60815..1e29d0461 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1461,7 +1461,8 @@ class FormHelper extends AppHelper { $hiddenAttributes = array( 'value' => '', 'id' => $attributes['id'] . ($style ? '' : '_'), - 'secure' => false + 'secure' => false, + 'name' => $attributes['name'] ); $select[] = $this->hidden(null, $hiddenAttributes); } else { @@ -1495,7 +1496,7 @@ class FormHelper extends AppHelper { $selected, array(), $showParents, - array('escape' => $escapeOptions, 'style' => $style) + array('escape' => $escapeOptions, 'style' => $style, 'name' => $attributes['name']) )); $template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend'; @@ -2041,7 +2042,7 @@ class FormHelper extends AppHelper { $label['class'] = 'selected'; } - list($name) = array_values($this->_name()); + $name = $attributes['name']; if (empty($attributes['class'])) { $attributes['class'] = 'checkbox'; diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 51b2b5803..10f1e4b4b 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -3448,7 +3448,10 @@ class FormHelperTest extends CakeTestCase { * @return void */ function testInputMultipleCheckboxes() { - $result = $this->Form->input('Model.multi_field', array('options' => array('first', 'second', 'third'), 'multiple' => 'checkbox')); + $result = $this->Form->input('Model.multi_field', array( + 'options' => array('first', 'second', 'third'), + 'multiple' => 'checkbox' + )); $expected = array( array('div' => array('class' => 'input select')), array('label' => array('for' => 'ModelMultiField')), @@ -3477,7 +3480,10 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->input('Model.multi_field', array('options' => array('a' => 'first', 'b' => 'second', 'c' => 'third'), 'multiple' => 'checkbox')); + $result = $this->Form->input('Model.multi_field', array( + 'options' => array('a' => 'first', 'b' => 'second', 'c' => 'third'), + 'multiple' => 'checkbox' + )); $expected = array( array('div' => array('class' => 'input select')), array('label' => array('for' => 'ModelMultiField')), @@ -3506,7 +3512,12 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->input('Model.multi_field', array('options' => array('1' => 'first'), 'multiple' => 'checkbox', 'label' => false, 'div' => false)); + $result = $this->Form->input('Model.multi_field', array( + 'options' => array('1' => 'first'), + 'multiple' => 'checkbox', + 'label' => false, + 'div' => false + )); $expected = array( 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), @@ -3518,7 +3529,12 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->input('Model.multi_field', array('options' => array('2' => 'second'), 'multiple' => 'checkbox', 'label' => false, 'div' => false)); + $result = $this->Form->input('Model.multi_field', array( + 'options' => array('2' => 'second'), + 'multiple' => 'checkbox', + 'label' => false, + 'div' => false + )); $expected = array( 'input' => array('type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '', 'id' => 'ModelMultiField'), array('div' => array('class' => 'checkbox')), @@ -3531,6 +3547,34 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test that select() with multiple = checkbox works with overriding name attribute. + * + * @return void + */ + function testSelectCheckboxMultipleOverrideName() { + $result = $this->Form->input('category', array( + 'type' => 'select', + 'multiple' => 'checkbox', + 'name' => 'data[fish]', + 'options' => array('1', '2'), + 'div' => false, + 'label' => false, + )); + $expected = array( + 'input' => array('type' => 'hidden', 'name' => 'data[fish]', 'value' => '', 'id' => 'category'), + array('div' => array('class' => 'checkbox')), + array('input' => array('type' => 'checkbox', 'name' => 'data[fish][]', 'value' => '0', 'id' => 'Category0')), + array('label' => array('for' => 'Category0')), '1', '/label', + '/div', + array('div' => array('class' => 'checkbox')), + array('input' => array('type' => 'checkbox', 'name' => 'data[fish][]', 'value' => '1', 'id' => 'Category1')), + array('label' => array('for' => 'Category1')), '2', '/label', + '/div' + ); + $this->assertTags($result, $expected); + } + /** * testCheckbox method * From bfaaa6b8ba2422c7b9cec5c67a1ed81a8950388f Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 5 Sep 2010 23:52:45 +0530 Subject: [PATCH 22/24] Fixing unnecessary extra calls to 'afterFind' callback of 'hasMany' associated models. Closes #995 --- cake/libs/model/datasources/dbo_source.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index abe268294..ed5bbbf1d 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -54,7 +54,7 @@ class DboSource extends DataSource { /** * Caches result from query parsing operations. Cached results for both DboSource::name() and - * DboSource::conditions() will be stored here. Method caching uses `crc32()` which is + * DboSource::conditions() will be stored here. Method caching uses `crc32()` which is * fast but can collisions more easily than other hashing algorithms. If you have problems * with collisions, set DboSource::$cacheMethods to false. * @@ -519,7 +519,7 @@ class DboSource extends DataSource { * because the method uses a simple hashing algorithm it can infrequently have collisions. * Setting DboSource::$cacheMethods to false will disable the memory cache. * - * @param mixed $data Either a string with a column to quote. An array of columns to quote or an + * @param mixed $data Either a string with a column to quote. An array of columns to quote or an * object from DboSource::expression() or DboSource::identifier() * @return string SQL field * @access public @@ -845,6 +845,10 @@ class DboSource extends DataSource { $stack = array($assoc); $db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1, $stack); unset($db); + + if ($type === 'hasMany') { + $filtered []= $assoc; + } } } } From b491414a5101e06e579b2471ed215eb87c69a0be Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 6 Sep 2010 01:38:31 -0400 Subject: [PATCH 23/24] Changing gif to png, so baked apps have the correct icon. Fixes #1081 --- cake/console/templates/skel/webroot/css/cake.generic.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/skel/webroot/css/cake.generic.css b/cake/console/templates/skel/webroot/css/cake.generic.css index 4d0161f8c..7f978afc0 100644 --- a/cake/console/templates/skel/webroot/css/cake.generic.css +++ b/cake/console/templates/skel/webroot/css/cake.generic.css @@ -79,7 +79,7 @@ ul, li { } #header h1 { line-height:20px; - background: #003d4c url('../img/cake.icon.gif') no-repeat left; + background: #003d4c url('../img/cake.icon.png') no-repeat left; color: #fff; padding: 0px 30px; } From c60edfae6ddcdb1742415ce4287b2778a6f5df24 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 6 Sep 2010 16:46:41 -0400 Subject: [PATCH 24/24] Fixing issue where errors containing code = 500, were not actually converted to error500 when debug = 0. Making missingConnection, and missingTable into error500 errors. --- cake/libs/error.php | 3 ++- cake/libs/model/connection_manager.php | 2 +- cake/libs/model/model.php | 5 +++-- cake/tests/cases/libs/error.test.php | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cake/libs/error.php b/cake/libs/error.php index 45c043bf4..e8d7a0d6a 100644 --- a/cake/libs/error.php +++ b/cake/libs/error.php @@ -106,6 +106,7 @@ class ErrorHandler extends Object { if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($this)))) { $method = 'error'; } + if ($method !== 'error') { if (Configure::read('debug') == 0) { $parentClass = get_parent_class($this); @@ -116,7 +117,7 @@ class ErrorHandler extends Object { if (in_array(strtolower($method), $parentMethods)) { $method = 'error404'; } - if (isset($code) && $code == 500) { + if (isset($messages[0]['code']) && $messages[0]['code'] == 500) { $method = 'error500'; } } diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 723ad0994..b9e599481 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -239,7 +239,7 @@ class ConnectionManager extends Object { $this->_connectionsEnum[$name] = $this->__connectionData($config); } } else { - $this->cakeError('missingConnection', array(array('className' => 'ConnectionManager'))); + $this->cakeError('missingConnection', array(array('code' => 500, 'className' => 'ConnectionManager'))); } } diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 32a19a717..9a663204e 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -769,7 +769,8 @@ class Model extends Overloadable { if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) { return $this->cakeError('missingTable', array(array( 'className' => $this->alias, - 'table' => $this->tablePrefix . $tableName + 'table' => $this->tablePrefix . $tableName, + 'code' => 500 ))); } $this->_schema = null; @@ -2826,7 +2827,7 @@ class Model extends Overloadable { } if (empty($db) || !is_object($db)) { - return $this->cakeError('missingConnection', array(array('className' => $this->alias))); + return $this->cakeError('missingConnection', array(array('code' => 500, 'className' => $this->alias))); } } diff --git a/cake/tests/cases/libs/error.test.php b/cake/tests/cases/libs/error.test.php index 4b181c3e5..ec90a57e2 100644 --- a/cake/tests/cases/libs/error.test.php +++ b/cake/tests/cases/libs/error.test.php @@ -609,4 +609,22 @@ class ErrorHandlerTest extends CakeTestCase { $this->assertPattern('/Article<\/em> could not be found./', $result); $this->assertPattern('/(\/|\\\)article.php/', $result); } + +/** + * testing that having a code => 500 in the cakeError call makes an + * internal server error. + * + * @return void + */ + function testThatCode500Works() { + Configure::write('debug', 0); + ob_start(); + $TestErrorHandler = new TestErrorHandler('missingTable', array( + 'className' => 'Article', + 'table' => 'articles', + 'code' => 500 + )); + $result = ob_get_clean(); + $this->assertPattern('/

An Internal Error Has Occurred<\/h2>/', $result); + } }