Commit 974b49d1 authored by Dave Marshall's avatar Dave Marshall

Allow view listeners to be "skipped" by returning null

parent 50150276
......@@ -49,7 +49,7 @@ class ViewListenerWrapper
if ($response instanceof Response) {
$event->setResponse($response);
} else {
} else if (null !== $response) {
$event->setControllerResult($response);
}
}
......
......@@ -663,6 +663,24 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('Hello world', $response->getContent());
}
public function testViewListenersResponsesAreNotUsedIfNull()
{
$app = new Application();
$app->get('/foo', function() { return 'Hello world'; });
$app->view(function ($view) {
return 'Hello view listener';
});
$app->view(function ($view) {
return null;
});
$response = $app->handle(Request::create('/foo'));
$this->assertEquals('Hello view listener', $response->getContent());
}
}
class FooController
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment