瀏覽代碼

[ZF-10199] Zend_Application:

- Fixed change done in r18273 applied too the Zend_Application_Bootstrap_BootstrapAbstract::hasOption().

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22664 44c647ce-9c0f-0410-b52a-842ac1e357ba
ramon 15 年之前
父節點
當前提交
c9cefe0419

+ 1 - 1
library/Zend/Application/Bootstrap/BootstrapAbstract.php

@@ -163,7 +163,7 @@ abstract class Zend_Application_Bootstrap_BootstrapAbstract
      */
     public function hasOption($key)
     {
-        return in_array($key, $this->_optionKeys);
+        return in_array(strtolower($key), $this->_optionKeys);
     }
 
     /**

+ 25 - 1
tests/Zend/Application/Bootstrap/BootstrapAbstractTest.php

@@ -729,7 +729,7 @@ class Zend_Application_Bootstrap_BootstrapAbstractTest extends PHPUnit_Framework
         $bootstrap = new Zend_Application_Bootstrap_Bootstrap($this->application);
         $bootstrap->setApplication($bootstrap);
     }
-    
+
     /**
      * @group ZF-7696
      */
@@ -746,6 +746,30 @@ class Zend_Application_Bootstrap_BootstrapAbstractTest extends PHPUnit_Framework
         $bootstrap = new Zf7696Bootstrap($this->application);
         $bootstrap->bootstrap(array('modules'));
     }
+
+    /**
+     * @group ZF-10199
+     */
+    public function testHasOptionShouldTreatOptionKeysAsCaseInsensitive()
+    {
+        $application = $this->application;
+        $application->setOptions(array(
+            'fooBar' => 'baz',
+        ));
+        $this->assertTrue($application->getBootstrap()->hasOption('FooBar'));
+    }
+
+    /**
+     * @group ZF-10199
+     */
+    public function testGetOptionShouldTreatOptionKeysAsCaseInsensitive()
+    {
+        $application = $this->application;
+        $application->setOptions(array(
+            'fooBar' => 'baz',
+        ));
+        $this->assertEquals('baz', $application->getBootstrap()->getOption('FooBar'));
+    }
 }
 
 class Zend_Application_Bootstrap_BootstrapAbstractTest_View