prepareNotFoundViewModel listner - eventResult as ViewModel if set #2286

merged 3 commits into from Sep 10, 2012


None yet
3 participants

AndrejAndb commented Sep 1, 2012

use case:

public function indexAction() {
$viewModel->setVariable('message', 'not found article');
return $viewModel;

or simple:
return 'not found article';

This pull request fails (merged 850a060 into 3a4cee6).

This pull request fails (merged 758f399 into 3a4cee6).

This pull request fails (merged c519377 into 3a4cee6).


AndrejAndb commented Sep 1, 2012

Travis error:
The "" file could not be downloaded: failed to open stream: HTTP request failed!
before_install: 'php composer.phar install --dev' returned false.

This pull request must be passes :)

AndrejAndb closed this Sep 1, 2012

AndrejAndb reopened this Sep 1, 2012

This pull request passes (merged c519377 into 3a4cee6).


weierophinney commented Sep 4, 2012

Just to clarify, this is to re-use a returned view model in a 404 response, instead of automatically substituting the not-found view model?


AndrejAndb commented Sep 4, 2012



AndrejAndb commented Sep 4, 2012

Now the event handler just simply replaces ViewModel

@weierophinney weierophinney commented on the diff Sep 10, 2012

+ $event->setResponse($response);
+ $response->setStatusCode(404);
+ $event->setResult(null);
+ $testCase = array(
+ 'assertEquals' => array (
+ 'bar',
+ new ViewModel(array('message' => 'bar')),
+ ),
+ 'assertTrue' => array (
+ null,
+ new ViewModel(),
+ )
+ );
+ foreach ($testCase as $type => $results) {

weierophinney Sep 10, 2012


This test should use a dataProvider, instead of having the array of values/assertions and foreach loop.

@weierophinney weierophinney added a commit that referenced this pull request Sep 10, 2012

@weierophinney weierophinney [#2286] Test cleanup
- Used data provider instead of foreach loop in test case

weierophinney merged commit c519377 into zendframework:master Sep 10, 2012

1 check passed

default The Travis build passed

weierophinney commented Sep 10, 2012

I did the change to use a dataProvider as noted in a comment. Changes merged to release and master branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment