From ac068802418ff00167070d9ffddf33138d385b8c Mon Sep 17 00:00:00 2001 From: dogmatic69 Date: Tue, 28 Feb 2012 16:05:24 +0000 Subject: [PATCH] making the name lowercase in the addDetector method so that it will be found in the is() method fixes #2622 with tests. --- lib/Cake/Network/CakeRequest.php | 1 + lib/Cake/Test/Case/Network/CakeRequestTest.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 9f8544c60..a81bd488c 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -516,6 +516,7 @@ class CakeRequest implements ArrayAccess { * @return void */ public function addDetector($name, $options) { + $name = strtolower($name); if (isset($this->_detectors[$name]) && isset($options['options'])) { $options = Set::merge($this->_detectors[$name], $options); } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 7c51f1710..0fc149822 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -793,6 +793,11 @@ class CakeRequestTest extends CakeTestCase { $_SERVER['TEST_VAR'] = 'wrong'; $this->assertFalse($request->is('compare'), 'Value mis-match failed.'); + + $request->addDetector('compareCamelCase', array('env' => 'TEST_VAR', 'value' => 'foo')); + + $_SERVER['TEST_VAR'] = 'foo'; + $this->assertTrue($request->is('compareCamelCase'), 'Value match failed.'); $request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/')); $_SERVER['TEST_VAR'] = 'banana';