Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'hotfix/3186' into develop

Forward port #3186
  • Loading branch information...
commit 497899bb770d753f08bd519c2baea6e87bfb9f16 2 parents 177846d + 819247b
@weierophinney weierophinney authored
View
5 library/Zend/Mvc/Controller/AbstractActionController.php
@@ -10,6 +10,7 @@
namespace Zend\Mvc\Controller;
+use Zend\Http\Response as HttpResponse;
use Zend\Mvc\Exception;
use Zend\Mvc\MvcEvent;
use Zend\View\Model\ViewModel;
@@ -51,7 +52,9 @@ public function notFoundAction()
$event = $this->getEvent();
$routeMatch = $event->getRouteMatch();
- $response->setStatusCode(404);
+ if ($response instanceof HttpResponse) {
+ $response->setStatusCode(404);
+ }
$routeMatch->setParam('action', 'not-found');
return new ViewModel(array(
View
20 tests/ZendTest/Mvc/Controller/ActionControllerTest.php
@@ -11,7 +11,9 @@
namespace ZendTest\Mvc\Controller;
use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Console\Response as ConsoleResponse;
use Zend\EventManager\SharedEventManager;
+use Zend\EventManager\StaticEventManager;
use Zend\Http\Request;
use Zend\Http\Response;
use Zend\Mvc\Controller\PluginManager;
@@ -27,8 +29,10 @@ class ActionControllerTest extends TestCase
public function setUp()
{
+ StaticEventManager::resetInstance();
$this->controller = new TestAsset\SampleController();
$this->request = new Request();
+ $this->response = null;
$this->routeMatch = new RouteMatch(array('controller' => 'controller-sample'));
$this->event = new MvcEvent();
$this->event->setRouteMatch($this->routeMatch);
@@ -194,4 +198,20 @@ public function testMethodOverloadingShouldInvokePluginAsFunctorIfPossible()
$this->controller->layout('alternate/layout');
$this->assertEquals('alternate/layout', $model->getTemplate());
}
+
+ /**
+ * @group 3186
+ */
+ public function testNotFoundActionReturnsSuccessfullyForConsoleResponse()
+ {
+ $response = new ConsoleResponse();
+ $result = $this->controller->dispatch($this->request, $response);
+ $testResponse = $this->controller->getResponse();
+ $this->assertSame($response, $testResponse);
+ $this->assertInstanceOf('Zend\View\Model\ModelInterface', $result);
+ $this->assertEquals('content', $result->captureTo());
+ $vars = $result->getVariables();
+ $this->assertArrayHasKey('content', $vars, var_export($vars, 1));
+ $this->assertContains('Page not found', $vars['content']);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.