robap/php-router — Issue #7: Router::getUrl does not work properly
Author: robap
Created: 2012-01-28 17:40:17+00:00
State: open

When similarly named dynamic parts are used, getUrl fails.

This unit test should be added to RouterTest and applicable changes to Router::getUrl should be made:

public function testGetUrlWithSimilarlyNamedDynamicParts()
{
$route = $this->getMock('Route');
$route->expects($this->atLeastOnce())
->method('getDynamicElements')
->will($this->returnValue(array(
':something' => ':something',
':some' => ':some'
)));
$route->expects($this->atLeastOnce())
->method('getPath')
->will($this->returnValue('/:something/:some'));

$router = new Router();
$router->addRoute('the_route', $route);
$url = $router->getUrl('the_route', array(
':something' => 'foo',
':some' => 'bar'
));

$this->assertEquals($url, '/foo/bar');

$url = $router->getUrl('the_route', array(
':some' => 'bar',
':something' => 'foo'
));

$this->assertEquals($url, '/foo/bar');
}