Added test to show (deprecated?) support of string status codes in redirect().

Fixed fail on string status codes in redirect().

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7410 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
TommyO 2008-08-01 11:27:53 +00:00
parent 8284872b82
commit 570145d568
2 changed files with 16 additions and 6 deletions

View file

@ -540,7 +540,7 @@ class Controller extends Object {
} }
if (isset($codes[$status])) { if (isset($codes[$status])) {
$code = $status = $codes[$status]; $code = $msg = $codes[$status];
if (is_numeric($status)) { if (is_numeric($status)) {
$code = $status; $code = $status;
} }

View file

@ -539,6 +539,7 @@ class ControllerTest extends CakeTestCase {
Mock::generatePartial('Controller', 'MockController', array('header')); Mock::generatePartial('Controller', 'MockController', array('header'));
App::import('Helper', 'Cache'); App::import('Helper', 'Cache');
// $codes = array_merge($codes, array_flip($codes));
foreach ($codes as $code => $msg) { foreach ($codes as $code => $msg) {
$MockController =& new MockController(); $MockController =& new MockController();
$MockController->components = array('Test'); $MockController->components = array('Test');
@ -547,6 +548,15 @@ class ControllerTest extends CakeTestCase {
$MockController->expectCallCount('header', 2); $MockController->expectCallCount('header', 2);
$MockController->redirect($url, (int) $code, false); $MockController->redirect($url, (int) $code, false);
} }
$codes = array_flip($codes);
foreach ($codes as $code => $msg) {
$MockController =& new MockController();
$MockController->components = array('Test');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->expectCallCount('header', 2);
$MockController->redirect($url, $code, false);
}
} }
/** /**
* testMergeVars method * testMergeVars method