diff --git a/cake/libs/router.php b/cake/libs/router.php index b2b7cac9d..1cea57ec6 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -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; } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index fc6aec324..da7c1199f 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -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'))); + } +} ?> \ No newline at end of file