Permalink
Browse files

Routing condition bugfix

  • Loading branch information...
marco-jantke authored and fabpot committed Jan 9, 2014
1 parent 07de761 commit 0a2bb7b476fc3858a96d239923b21d08b5eeae02
@@ -167,6 +167,9 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $condition) {
$subCollection->setCondition($condition);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);
}
@@ -146,6 +146,7 @@ protected function parseImport(RouteCollection $collection, array $config, $path
$requirements = isset($config['requirements']) ? $config['requirements'] : array();
$options = isset($config['options']) ? $config['options'] : array();
$host = isset($config['host']) ? $config['host'] : null;
$condition = isset($config['condition']) ? $config['condition'] : null;
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
$methods = isset($config['methods']) ? $config['methods'] : null;
@@ -157,6 +158,9 @@ protected function parseImport(RouteCollection $collection, array $config, $path
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $condition) {
$subCollection->setCondition($condition);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);
}
@@ -20,4 +20,6 @@
<option key="compiler_class">RouteCompiler</option>
<condition>context.getMethod() == "GET"</condition>
</route>
<route id="blog_show_inherited" path="/blog/{slug}" />
</routes>
@@ -17,3 +17,6 @@ blog_show_legacy:
condition: 'context.getMethod() == "GET"'
options:
compiler_class: RouteCompiler
blog_show_inherited:
path: /blog/{slug}
@@ -8,5 +8,6 @@
<default key="foo">123</default>
<requirement key="foo">\d+</requirement>
<option key="foo">bar</option>
<condition>context.getMethod() == "POST"</condition>
</import>
</routes>
@@ -5,3 +5,4 @@ _blog:
requirements: { 'foo': '\d+' }
options: { 'foo': 'bar' }
host: ""
condition: 'context.getMethod() == "POST"'
@@ -34,10 +34,12 @@ public function testLoadWithRoute()
$routeCollection = $loader->load('validpattern.xml');
$routes = $routeCollection->all();
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertCount(3, $routes, 'Three routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
$identicalRoutes = array_slice($routes, 0, 2);
foreach ($identicalRoutes as $route) {
$this->assertSame('/blog/{slug}', $route->getPath());
$this->assertSame('{locale}.example.com', $route->getHost());
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
@@ -72,7 +74,7 @@ public function testLoadWithImport()
$routeCollection = $loader->load('validresource.xml');
$routes = $routeCollection->all();
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertCount(3, $routes, 'Three routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
@@ -81,6 +83,7 @@ public function testLoadWithImport()
$this->assertSame('\d+', $route->getRequirement('foo'));
$this->assertSame('bar', $route->getOption('foo'));
$this->assertSame('', $route->getHost());
$this->assertSame('context.getMethod() == "POST"', $route->getCondition());
}
}
@@ -68,10 +68,12 @@ public function testLoadWithRoute()
$routeCollection = $loader->load('validpattern.yml');
$routes = $routeCollection->all();
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertCount(3, $routes, 'Three routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
$identicalRoutes = array_slice($routes, 0, 2);
foreach ($identicalRoutes as $route) {
$this->assertSame('/blog/{slug}', $route->getPath());
$this->assertSame('{locale}.example.com', $route->getHost());
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
@@ -89,7 +91,7 @@ public function testLoadWithResource()
$routeCollection = $loader->load('validresource.yml');
$routes = $routeCollection->all();
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertCount(3, $routes, 'Three routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
@@ -98,6 +100,8 @@ public function testLoadWithResource()
$this->assertSame('\d+', $route->getRequirement('foo'));
$this->assertSame('bar', $route->getOption('foo'));
$this->assertSame('', $route->getHost());
$this->assertSame('context.getMethod() == "POST"', $route->getCondition());
}
}
}

0 comments on commit 0a2bb7b

Please sign in to comment.