Details
-
Type:
Docs: Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.8.4
-
Fix Version/s: Next Minor Release
-
Component/s: Zend_Test_PHPUnit
-
Labels:None
Description
In normal operation, $this->_redirect() exits after performing the redirect. This behaviour is disabled by controller test case via $redirector->setExit(false)--in test mode, the exit is not applied. The result of this is that actions that use _redirect() like a "return" or exit behave differently in test mode.
i.e. actions with the following pattern:
if ($some_condition) {
$this->_redirect("foo");
}
if ($other_condition) {
$this->_redirect("bar");
}
$this->_redirect("default");
will always be redirected to "default" in test mode.
If this issue cannot be fixed, it would at least be helpful to place a warning in 52.2.3.3 saying that _redirect() must be followed by return in actions, otherwise the redirect assertion may not behave as expected.
Issue Links
| This issue is related to: | ||||
| ZF-5619 | ::assertRedirectTo does not work as expected |
|
|
|
| This issue is related to: | ||||
| ZF-7496 | Impossible to use Zend_Test_PHPUnit_ControllerTestCase to test redirects issued in preDispatch() hooks |
|
|
|
| ZF-11507 | CLONE - Impossible to use Zend_Test_PHPUnit_ControllerTestCase to test redirects issued in preDispatch() hooks |
|
|
|
It's best with both _redirect() and _forward() (as well as when using the redirector action helper) to call return():
This will ensure that if the exit flag is disabled, the application will work in the same way.
I will add this verbiage to the manual.