[Routing] Added tests for PhpMatcherDumper changes

This commit is contained in:
Jordi Boggiano 2011-02-10 23:03:19 +01:00 committed by Fabien Potencier
parent fe694de746
commit 2ed0b975f1
2 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,20 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz2'));
}
if (rtrim($url, '/') === '/test/baz3') {
if (substr($url, -1) !== '/') {
return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$url.'/', 'permanent' => true, '_route' => 'baz3');
}
return array_merge($this->mergeDefaults(array(), array ()), array('_route' => 'baz3'));
}
if (0 === strpos($url, '/test') && preg_match('#^/test/(?P<foo>[^/\.]+?)/?$#x', $url, $matches)) {
if (substr($url, -1) !== '/') {
return array('_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', 'url' => $this->context['base_url'].$url.'/', 'permanent' => true, '_route' => 'baz4');
}
return array_merge($this->mergeDefaults($matches, array ()), array('_route' => 'baz4'));
}
return false;
}
}

View File

@ -44,6 +44,12 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
$collection->add('baz2', new Route(
'/test/baz.html'
));
$collection->add('baz3', new Route(
'/test/baz3/'
));
$collection->add('baz4', new Route(
'/test/{foo}/'
));
$dumper = new PhpMatcherDumper($collection);
$this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.php', $dumper->dump(), '->dump() dumps basic routes to the correct PHP file.');