Ver Fonte

ZF-10725: remove duplicate regex, and add test for comment

- Removed duplicate regex introduced in r24216
- Added unit test to ensure that route /Controller/Action results in view script
  controller/action.phtml

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24281 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew há 14 anos atrás
pai
commit
7f09985159

+ 0 - 8
library/Zend/Controller/Action/Helper/ViewRenderer.php

@@ -630,14 +630,6 @@ class Zend_Controller_Action_Helper_ViewRenderer extends Zend_Controller_Action_
         $replacePattern = array('/[^a-z0-9]+$/i', '/^[^a-z0-9]+/i');
         $vars['action'] = preg_replace($replacePattern, '', $vars['action']);
 
-        // Remove non-alphanumeric characters from action name
-        // see ZF-10725
-        $vars['action'] = preg_replace(
-            array('/[^a-z0-9]+$/', '/^[^a-z0-9]+/'),
-            array('', ''),
-            $vars['action']
-        );
-
         $inflector = $this->getInflector();
         if ($this->getNoController() || $this->getNeverController()) {
             $this->_setInflectorTarget($this->getViewScriptPathNoControllerSpec());

+ 14 - 1
tests/Zend/Controller/Action/Helper/ViewRendererTest.php

@@ -885,7 +885,6 @@ class Zend_Controller_Action_Helper_ViewRendererTest extends PHPUnit_Framework_T
         $this->helper->setActionController($controller);
         $scriptName = $this->helper->getViewScript();
         $this->assertEquals('foo/my-bar.phtml', $scriptName);
-
     }
     
     /**
@@ -909,6 +908,20 @@ class Zend_Controller_Action_Helper_ViewRendererTest extends PHPUnit_Framework_T
     {
         return str_replace(array('/', '\\'), '/', $path);
     }
+
+    /**
+     * @group ZF-10725
+     */
+    public function testActionsWithLeadingCapitalLettersShouldNotInvokeTruncatedViewScripts()
+    {
+        $this->request->setModuleName('default')
+                      ->setControllerName('Controller')
+                      ->setActionName('Action');
+        $controller = new Bar_IndexController($this->request, $this->response, array());
+        $this->helper->setActionController($controller);
+        $scriptName = $this->helper->getViewScript();
+        $this->assertEquals('controller/action.phtml', $scriptName);
+    }
 }
 
 // Call Zend_Controller_Action_Helper_ViewRendererTest::main() if this source file is executed directly.