Bläddra i källkod

ZF-8041: added patch provided by Olek

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19090 44c647ce-9c0f-0410-b52a-842ac1e357ba
bate 16 år sedan
förälder
incheckning
47b540b9ef
2 ändrade filer med 31 tillägg och 0 borttagningar
  1. 1 0
      library/Zend/Layout/Controller/Plugin/Layout.php
  2. 30 0
      tests/Zend/Layout/PluginTest.php

+ 1 - 0
library/Zend/Layout/Controller/Plugin/Layout.php

@@ -112,6 +112,7 @@ class Zend_Layout_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstra
 
         // Return early if forward detected
         if (!$request->isDispatched()
+            || $this->getResponse()->isRedirect()
             || ($layout->getMvcSuccessfulActionOnly()
                 && (!empty($helper) && !$helper->isActionControllerSuccessful())))
         {

+ 30 - 0
tests/Zend/Layout/PluginTest.php

@@ -202,6 +202,36 @@ class Zend_Layout_PluginTest extends PHPUnit_Framework_TestCase
         $this->assertContains('Application content', $body);
         $this->assertNotContains('Site Layout', $body);
     }
+
+    /**
+     * @group ZF-8041
+     */
+    public function testPostDispatchDoesNotRenderLayoutWhenResponseRedirected()
+    {
+        $front    = Zend_Controller_Front::getInstance();
+        $request  = new Zend_Controller_Request_Simple();
+        $response = new Zend_Controller_Response_Cli();
+
+        $request->setDispatched(true);
+        $response->setHttpResponseCode(302);
+        $response->setBody('Application content');
+        $front->setRequest($request)
+              ->setResponse($response);
+
+        $layout = Zend_Layout::startMvc();
+        $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts')
+               ->setLayout('plugin.phtml')
+               ->setMvcSuccessfulActionOnly(false)
+               ->disableInflector();
+
+        $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout');
+        $plugin->setResponse($response);
+        $plugin->postDispatch($request);
+
+        $body = $response->getBody();
+        $this->assertContains('Application content', $body);
+        $this->assertNotContains('Site Layout', $body);
+    }
 }
 
 /**