Skip to content

Commit c00a05c

Browse files
committed
Fixed issue in RouteCollector
1 parent ccb90b5 commit c00a05c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Router/RouteCollector.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ public function getData()
113113
*/
114114
public function map($route, $name, $handler, array $methods = array('GET'))
115115
{
116-
if (null === $name) {
117-
$this->addRoute($methods, $route, $handler);
118-
}
116+
foreach ($methods as $method) {
117+
if (null === $name) {
118+
$this->addRoute($method, $route, $handler);
119+
}
119120

120-
$this->addNamedRoute($name, $methods, $route, $handler);
121+
$this->addNamedRoute($name, $method, $route, $handler);
122+
}
121123
}
122124

123125
/**

tests/Router/RouteCollectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class RouteCollectorTest extends \PHPUnit_Framework_TestCase
1919
public function testFunctionality()
2020
{
2121
$parser = $this->getMock('FastRoute\RouteParser');
22-
$parser->expects($this->exactly(6))->method('parse')
22+
$parser->expects($this->exactly(7))->method('parse')
2323
->will($this->returnArgument(1));
2424
$generator = $this->getMockForAbstractClass('Nice\Router\NamedDataGeneratorInterface');
2525
$generator->expects($this->exactly(2))->method('addRoute');
26-
$generator->expects($this->exactly(4))->method('addNamedRoute');
26+
$generator->expects($this->exactly(5))->method('addNamedRoute');
2727
$generator->expects($this->once())->method('getData');
2828

2929
$collector = new ConcreteRouteCollector($parser, $generator);

0 commit comments

Comments
 (0)