"Closes #3587, Multiple resource routes"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6257 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-25 10:25:42 +00:00
parent 9bed2fa6d7
commit 75b5623f33
2 changed files with 25 additions and 2 deletions

View file

@ -412,7 +412,17 @@ class Router extends Object {
} else {
$header = 'http_' . $header[1];
}
if (env(strtoupper($header)) != $val) {
if (!is_array($val)) {
$val = array($val);
}
$h = false;
foreach ($val as $v) {
if (env(strtoupper($header)) == $v) {
$h = true;
}
}
if (!$h) {
return false;
}
}

View file

@ -967,6 +967,19 @@ class RouterTest extends UnitTestCase {
$expected = '/test/test_another_action/locale:badness';
$this->assertEqual($result, $expected);
}
}
function testMultiResourceRoute() {
$this->router->reload();
$this->router->connect('/:controller', array('action' => 'index', '[method]' => array('GET', 'POST')));
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = $this->router->parse('/posts');
debug($result);
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => array('GET', 'POST')));
$_SERVER['REQUEST_METHOD'] = 'POST';
$result = $this->router->parse('/posts');
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => array('GET', 'POST')));
}
}
?>