فهرست منبع

ZF-11793: ContextSwitch action helper should return all contexts when argument is null

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24864 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan 13 سال پیش
والد
کامیت
71c3ef4ed1

+ 1 - 1
library/Zend/Controller/Action/Helper/ContextSwitch.php

@@ -1304,7 +1304,6 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action
         if (null === $controller) {
             return array();
         }
-        $action     = (string) $action;
         $contextKey = $this->_contextKey;
 
         if (!isset($controller->$contextKey)) {
@@ -1312,6 +1311,7 @@ class Zend_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action
         }
 
         if (null !== $action) {
+            $action = (string) $action;
             if (isset($controller->{$contextKey}[$action])) {
                 return $controller->{$contextKey}[$action];
             } else {

+ 14 - 0
tests/Zend/Controller/Action/Helper/ContextSwitchTest.php

@@ -919,6 +919,20 @@ class Zend_Controller_Action_Helper_ContextSwitchTest extends PHPUnit_Framework_
         $this->assertContains('foo', $suffix, $suffix);
         $this->assertNotContains('foo.foo', $suffix, $suffix);
     }
+
+    /**
+     * @group ZF-11793
+     */
+    public function testGetActionContextsReturnsFullListWhenArgumentIsNull()
+    {
+        $expected = array(
+            'foo' => array('xml'),
+            'bar' => array('xml', 'json'),
+            'all' => array('json','xml')
+        );
+        $actual = $this->helper->getActionContexts(null);
+        $this->assertEquals($expected, $actual);
+    }
 }
 
 class Zend_Controller_Action_Helper_ContextSwitchTestController extends Zend_Controller_Action