diff --git a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php
index a50da26648c76..3919e41ac6d2f 100644
--- a/src/Symfony/Component/Routing/Loader/XmlFileLoader.php
+++ b/src/Symfony/Component/Routing/Loader/XmlFileLoader.php
@@ -126,8 +126,8 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p
$node->removeAttribute('pattern');
}
- $schemes = array_filter(explode(' ', $node->getAttribute('schemes')));
- $methods = array_filter(explode(' ', $node->getAttribute('methods')));
+ $schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY);
+ $methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY);
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
@@ -154,8 +154,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
$type = $node->getAttribute('type');
$prefix = $node->getAttribute('prefix');
$host = $node->hasAttribute('host') ? $node->getAttribute('host') : null;
- $schemes = $node->hasAttribute('schemes') ? array_filter(explode(' ', $node->getAttribute('schemes'))) : null;
- $methods = $node->hasAttribute('methods') ? array_filter(explode(' ', $node->getAttribute('methods'))) : null;
+ $schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
+ $methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
list($defaults, $requirements, $options) = $this->parseConfigs($node, $path);
diff --git a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
index bbd918c3f5167..ecd852be8aad0 100644
--- a/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
+++ b/src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
@@ -17,16 +17,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -49,8 +39,8 @@
-
-
+
+
@@ -60,8 +50,8 @@
-
-
+
+
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml b/src/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml
index 52719be167eec..4ea4115f281a1 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/missing_id.xml
@@ -4,5 +4,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml b/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml
index 79ec6e9169227..bdd6a4732999a 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/namespaceprefix.xml
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
MyBundle:Blog:show
\w+
en|fr|de
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml b/src/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml
index a9b72f392958e..755e44304ce78 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/nonvalid.xml
@@ -4,9 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
MyBundle:Blog:show
GET
-
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml b/src/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml
index cba82f3d299de..a46961eee5f26 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/nonvalidroute.xml
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
MyBundle:Blog:show
GET
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php
index 9841458a63673..b8bbbb5f8f01d 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php
@@ -6,18 +6,18 @@
$collection->add('blog_show', new Route(
'/blog/{slug}',
array('_controller' => 'MyBlogBundle:Blog:show'),
- array('_method' => 'GET', 'locale' => '\w+', '_scheme' => 'https'),
+ array('locale' => '\w+'),
array('compiler_class' => 'RouteCompiler'),
- '{locale}.example.com'
+ '{locale}.example.com',
+ array('https'),
+ array('GET','POST','put','OpTiOnS')
));
$collection->add('blog_show_legacy', new Route(
'/blog/{slug}',
array('_controller' => 'MyBlogBundle:Blog:show'),
- array('locale' => '\w+'),
+ array('_method' => 'GET|POST|put|OpTiOnS', '_scheme' => 'https', 'locale' => '\w+',),
array('compiler_class' => 'RouteCompiler'),
- '{locale}.example.com',
- array('https'),
- array('GET')
+ '{locale}.example.com'
));
return $collection;
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml
index df3a256acf8c2..b4de9efb1fe6a 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
MyBundle:Blog:show
\w+
@@ -12,8 +12,8 @@
MyBundle:Blog:show
- GET
- https
+ GET|POST|put|OpTiOnS
+ hTTps
\w+
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml
index 419923e9c36a9..4ada8832197b8 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml
@@ -1,17 +1,17 @@
blog_show:
path: /blog/{slug}
- defaults: { _controller: MyBlogBundle:Blog:show }
+ defaults: { _controller: "MyBundle:Blog:show" }
host: "{locale}.example.com"
requirements: { 'locale': '\w+' }
- methods: ['GET']
+ methods: ['GET','POST','put','OpTiOnS']
schemes: ['https']
options:
compiler_class: RouteCompiler
blog_show_legacy:
pattern: /blog/{slug}
- defaults: { _controller: MyBlogBundle:Blog:show }
+ defaults: { _controller: "MyBundle:Blog:show" }
host: "{locale}.example.com"
- requirements: { '_method': 'GET', 'locale': '\w+', _scheme: 'https' }
+ requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' }
options:
compiler_class: RouteCompiler
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml
index dd457dc821148..295c3cc428a6e 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.xml
@@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
123
\d+
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml
index 1f5644e04b028..495ed854d1dd1 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.yml
@@ -1,7 +1,7 @@
-blog_show:
+_blog:
resource: validpattern.yml
prefix: /{foo}
defaults: { 'foo': '123' }
requirements: { 'foo': '\d+' }
options: { 'foo': 'bar' }
- host: "{locale}.example.com"
+ host: ""
diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
index 7494fb01d9deb..18b166fc558cb 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
@@ -44,12 +44,12 @@ public function testLoadWithRoute()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
}
}
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
index b67ebf3486030..833862e218154 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
@@ -43,14 +43,16 @@ public function testLoadWithRoute()
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $route = $routes['blog_show'];
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('\w+', $route->getRequirement('locale'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+
+ foreach ($routes as $route) {
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
+ }
}
public function testLoadWithNamespacePrefix()
@@ -61,12 +63,12 @@ public function testLoadWithNamespacePrefix()
$this->assertCount(1, $routeCollection->all(), 'One route is loaded');
$route = $routeCollection->get('blog_show');
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('\w+', $route->getRequirement('slug'));
- $this->assertEquals('en|fr|de', $route->getRequirement('_locale'));
- $this->assertEquals('{_locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{_locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('slug'));
+ $this->assertSame('en|fr|de', $route->getRequirement('_locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
}
public function testLoadWithImport()
@@ -79,12 +81,11 @@ public function testLoadWithImport()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
- $this->assertEquals('MyBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
- $this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
- $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
- $this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
- $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
+ $this->assertSame('/{foo}/blog/{slug}', $route->getPath());
+ $this->assertSame('123', $route->getDefault('foo'));
+ $this->assertSame('\d+', $route->getRequirement('foo'));
+ $this->assertSame('bar', $route->getOption('foo'));
+ $this->assertSame('', $route->getHost());
}
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
index b6234bf8e5d12..a3e934cef02bf 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
@@ -73,7 +73,7 @@ public function testLoadSpecialRouteName()
$this->assertSame('/true', $route->getPath());
}
- public function testLoadWithPattern()
+ public function testLoadWithRoute()
{
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
$routeCollection = $loader->load('validpattern.yml');
@@ -83,13 +83,13 @@ public function testLoadWithPattern()
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
foreach ($routes as $route) {
- $this->assertEquals('/blog/{slug}', $route->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
- $this->assertEquals('GET', $route->getRequirement('_method'));
- $this->assertEquals('https', $route->getRequirement('_scheme'));
- $this->assertEquals('\w+', $route->getRequirement('locale'));
- $this->assertEquals('{locale}.example.com', $route->getHost());
- $this->assertEquals('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertSame('/blog/{slug}', $route->getPath());
+ $this->assertSame('{locale}.example.com', $route->getHost());
+ $this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
+ $this->assertSame('\w+', $route->getRequirement('locale'));
+ $this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
+ $this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
+ $this->assertEquals(array('https'), $route->getSchemes());
}
}
@@ -101,11 +101,13 @@ public function testLoadWithResource()
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
- $this->assertEquals('/{foo}/blog/{slug}', $routes['blog_show']->getPath());
- $this->assertEquals('MyBlogBundle:Blog:show', $routes['blog_show']->getDefault('_controller'));
- $this->assertEquals('123', $routes['blog_show']->getDefault('foo'));
- $this->assertEquals('\d+', $routes['blog_show']->getRequirement('foo'));
- $this->assertEquals('bar', $routes['blog_show']->getOption('foo'));
- $this->assertEquals('{locale}.example.com', $routes['blog_show']->getHost());
+
+ foreach ($routes as $route) {
+ $this->assertSame('/{foo}/blog/{slug}', $route->getPath());
+ $this->assertSame('123', $route->getDefault('foo'));
+ $this->assertSame('\d+', $route->getRequirement('foo'));
+ $this->assertSame('bar', $route->getOption('foo'));
+ $this->assertSame('', $route->getHost());
+ }
}
}