diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 2385f32d4..a04ad3d4b 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -369,6 +369,7 @@ class FileEngine extends CacheEngine { unlink($object->getPathName()); } } + $this->_File = null; return true; } } diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 281865ee3..1f68f496c 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -74,7 +74,8 @@ class CakeResponse { 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', - 504 => 'Gateway Time-out' + 504 => 'Gateway Time-out', + 505 => 'Unsupported Version' ); /** diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 740a439f3..3f05e5cbe 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -1093,7 +1093,8 @@ class Router { * @return CakeRoute Matching route object. */ public static function currentRoute() { - return self::$_currentRoute[count(self::$_currentRoute) - 1]; + $count = count(self::$_currentRoute) - 1; + return ($count >= 0) ? self::$_currentRoute[$count] : false; } /** diff --git a/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php index ed61017cb..de6de80c0 100644 --- a/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php @@ -411,6 +411,32 @@ class FileEngineTest extends CakeTestCase { $this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups')); } +/** + * Test that clearing with repeat writes works properly + */ + public function testClearingWithRepeatWrites() { + Cache::config('repeat', array( + 'engine' => 'File', 'groups' => array('users') + )); + + $this->assertTrue(Cache::write('user', 'rchavik', 'repeat')); + $this->assertEquals('rchavik', Cache::read('user', 'repeat')); + + Cache::delete('user', 'repeat'); + $this->assertEquals(false, Cache::read('user', 'repeat')); + + $this->assertTrue(Cache::write('user', 'ADmad', 'repeat')); + $this->assertEquals('ADmad', Cache::read('user', 'repeat')); + + Cache::clearGroup('users', 'repeat'); + $this->assertEquals(false, Cache::read('user', 'repeat')); + + $this->assertTrue(Cache::write('user', 'markstory', 'repeat')); + $this->assertEquals('markstory', Cache::read('user', 'repeat')); + + Cache::drop('repeat'); + } + /** * Tests that deleting from a groups-enabled config is possible * diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 1dbcc95a4..91934f9ef 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -361,7 +361,7 @@ class CakeResponseTest extends CakeTestCase { public function testHttpCodes() { $response = new CakeResponse(); $result = $response->httpCodes(); - $this->assertEquals(39, count($result)); + $this->assertEquals(40, count($result)); $result = $response->httpCodes(100); $expected = array(100 => 'Continue'); @@ -374,7 +374,7 @@ class CakeResponseTest extends CakeTestCase { $result = $response->httpCodes($codes); $this->assertTrue($result); - $this->assertEquals(41, count($response->httpCodes())); + $this->assertEquals(42, count($response->httpCodes())); $result = $response->httpCodes(1337); $expected = array(1337 => 'Undefined Unicorn'); @@ -383,7 +383,7 @@ class CakeResponseTest extends CakeTestCase { $codes = array(404 => 'Sorry Bro'); $result = $response->httpCodes($codes); $this->assertTrue($result); - $this->assertEquals(41, count($response->httpCodes())); + $this->assertEquals(42, count($response->httpCodes())); $result = $response->httpCodes(404); $expected = array(404 => 'Sorry Bro'); diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 109a1f293..3abe389c9 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2161,6 +2161,16 @@ class RouterTest extends CakeTestCase { $this->assertEquals(Router::stripPlugin($url, null), $url); } +/** + * testCurrentRouteWhenNonExistentRoute + * + * @return void + */ + public function testCurrentRouteWhenNonExistentRoute() { + $route = Router::currentRoute(); + $this->assertFalse($route); + } + /** * testCurrentRoute * diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index ed8f8a49a..cb2349909 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -8697,7 +8697,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->inputDefaults(array('required' => false)); $result = $this->Form->input('Contact.imrequired'); $expected = array( - 'div' => array('class' => 'input text required'), + 'div' => array('class' => 'input text'), 'label' => array('for' => 'ContactImrequired'), 'Imrequired', '/label', @@ -8711,6 +8711,23 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->input('Contact.imrequired', array('required' => false)); $this->assertTags($result, $expected); + + $result = $this->Form->input('Contact.imrequired', array('required' => true)); + $expected = array( + 'div' => array('class' => 'input text required'), + 'label' => array('for' => 'ContactImrequired'), + 'Imrequired', + '/label', + 'input' => array( + 'required' => 'required', 'type' => 'text', 'name' => 'data[Contact][imrequired]', + 'id' => 'ContactImrequired' + ), + '/div' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->input('Contact.imrequired', array('required' => null)); + $this->assertTags($result, $expected); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index c50a4fd36..d3b7f528d 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1271,8 +1271,10 @@ class FormHelper extends AppHelper { } elseif (is_array($div)) { $divOptions = array_merge($divOptions, $div); } - - if ($this->_introspectModel($this->model(), 'validates', $this->field())) { + if ( + $this->_extractOption('required', $options) !== false && + $this->_introspectModel($this->model(), 'validates', $this->field()) + ) { $divOptions = $this->addClass($divOptions, 'required'); } if (!isset($divOptions['tag'])) {