Permalink
Browse files

Merge branch 'hotfix/3186'

Close #3186
  • Loading branch information...
2 parents 2c3f7d3 + 819247b commit c8b8ffbbbb15da734784736e4adc2f0705fd2896 @weierophinney weierophinney committed Dec 11, 2012
@@ -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(
@@ -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']);
+ }
}

0 comments on commit c8b8ffb

Please sign in to comment.