prepareNotFoundViewModel listner - eventResult as ViewModel if set #2286

Merged
merged 3 commits into from Sep 10, 2012

Conversation

Projects
None yet
3 participants
Contributor

AndrejAndb commented Sep 1, 2012

use case:

public function indexAction() {
$this->getResponse()->setStatusCode(404);
$viewModel->setVariable('message', 'not found article');
return $viewModel;
}

or simple:
$this->getResponse()->setStatusCode(404);
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).

Contributor

AndrejAndb commented Sep 1, 2012

Travis error:
[RuntimeException]
The "http://packagist.org/packages-2012-03.json" 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).

Owner

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?

Contributor

AndrejAndb commented Sep 4, 2012

yes

Contributor

AndrejAndb commented Sep 4, 2012

Now the event handler just simply replaces ViewModel

@weierophinney weierophinney commented on the diff Sep 10, 2012

tests/ZendTest/Mvc/View/RouteNotFoundStrategyTest.php
+ $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

weierophinney Sep 10, 2012

Owner

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
67bc76f

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

1 check passed

default The Travis build passed
Details
Owner

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