From 73aa7d128b23a0124a97d4df56d3be8418ff3b34 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 6 Feb 2013 22:52:59 +0100 Subject: [PATCH] replaced usage of the deprecated pattern routing key (replaced with path) --- .../TestBundle/Resources/config/routing.yml | 12 +++++----- .../Resources/config/routing.yml | 16 ++++++------- .../Resources/config/localized_routing.yml | 12 +++++----- .../Resources/config/routing.yml | 18 +++++++-------- .../Fixtures/nonesense_resource_plus_path.yml | 2 +- .../nonesense_type_without_resource.yml | 2 +- .../Tests/Fixtures/special_route_name.yml | 2 +- .../Routing/Tests/Fixtures/validpattern.php | 11 ++++++++- .../Routing/Tests/Fixtures/validpattern.xml | 9 +++++++- .../Routing/Tests/Fixtures/validpattern.yml | 16 ++++++++++--- .../Tests/Loader/PhpFileLoaderTest.php | 17 ++++++++------ .../Tests/Loader/XmlFileLoaderTest.php | 23 +++++++++++-------- .../Tests/Loader/YamlFileLoaderTest.php | 21 +++++++++-------- 13 files changed, 99 insertions(+), 62 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml index 2a077856f6..d9b380ef8d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml @@ -1,23 +1,23 @@ session_welcome: - pattern: /session + path: /session defaults: { _controller: TestBundle:Session:welcome } session_welcome_name: - pattern: /session/{name} + path: /session/{name} defaults: { _controller: TestBundle:Session:welcome } session_logout: - pattern: /session_logout + path: /session_logout defaults: { _controller: TestBundle:Session:logout} session_setflash: - pattern: /session_setflash/{message} + path: /session_setflash/{message} defaults: { _controller: TestBundle:Session:setFlash} session_showflash: - pattern: /session_showflash + path: /session_showflash defaults: { _controller: TestBundle:Session:showFlash} profiler: - pattern: /profiler + path: /profiler defaults: { _controller: TestBundle:Profiler:index } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/config/routing.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/config/routing.yml index 0c9842bb9a..0a02730233 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/config/routing.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/CsrfFormLoginBundle/Resources/config/routing.yml @@ -1,30 +1,30 @@ form_login: - pattern: /login + path: /login defaults: { _controller: CsrfFormLoginBundle:Login:login } form_login_check: - pattern: /login_check + path: /login_check defaults: { _controller: CsrfFormLoginBundle:Login:loginCheck } form_login_homepage: - pattern: / + path: / defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_custom_target_path: - pattern: /foo + path: /foo defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_default_target_path: - pattern: /profile + path: /profile defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_login_redirect_to_protected_resource_after_login: - pattern: /protected-resource + path: /protected-resource defaults: { _controller: CsrfFormLoginBundle:Login:afterLogin } form_logout: - pattern: /logout_path + path: /logout_path form_secure_action: - pattern: /secure-but-not-covered-by-access-control + path: /secure-but-not-covered-by-access-control defaults: { _controller: CsrfFormLoginBundle:Login:secure } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/localized_routing.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/localized_routing.yml index a10bf9e101..964a74fe89 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/localized_routing.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/localized_routing.yml @@ -1,29 +1,29 @@ localized_login_path: - pattern: /{_locale}/login + path: /{_locale}/login defaults: { _controller: FormLoginBundle:Localized:login } requirements: { _locale: "^[a-z]{2}$" } localized_check_path: - pattern: /{_locale}/login_check + path: /{_locale}/login_check defaults: { _controller: FormLoginBundle:Localized:loginCheck } requirements: { _locale: "^[a-z]{2}$" } localized_default_target_path: - pattern: /{_locale}/profile + path: /{_locale}/profile defaults: { _controller: FormLoginBundle:Localized:profile } requirements: { _locale: "^[a-z]{2}$" } localized_logout_path: - pattern: /{_locale}/logout + path: /{_locale}/logout defaults: { _controller: FormLoginBundle:Localized:logout } requirements: { _locale: "^[a-z]{2}$" } localized_logout_target_path: - pattern: /{_locale}/ + path: /{_locale}/ defaults: { _controller: FormLoginBundle:Localized:homepage } requirements: { _locale: "^[a-z]{2}$" } localized_secure_path: - pattern: /{_locale}/secure/ + path: /{_locale}/secure/ defaults: { _controller: FormLoginBundle:Localized:secure } requirements: { _locale: "^[a-z]{2}$" } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/routing.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/routing.yml index c9684cec51..13788e1f96 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/routing.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/FormLoginBundle/Resources/config/routing.yml @@ -1,33 +1,33 @@ form_login: - pattern: /login + path: /login defaults: { _controller: FormLoginBundle:Login:login } form_login_check: - pattern: /login_check + path: /login_check defaults: { _controller: FormLoginBundle:Login:loginCheck } form_login_homepage: - pattern: / + path: / defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_custom_target_path: - pattern: /foo + path: /foo defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_default_target_path: - pattern: /profile + path: /profile defaults: { _controller: FormLoginBundle:Login:afterLogin } form_login_redirect_to_protected_resource_after_login: - pattern: /protected_resource + path: /protected_resource defaults: { _controller: FormLoginBundle:Login:afterLogin } highly_protected_resource: - pattern: /highly_protected_resource + path: /highly_protected_resource form_logout: - pattern: /logout_path + path: /logout_path form_secure_action: - pattern: /secure-but-not-covered-by-access-control + path: /secure-but-not-covered-by-access-control defaults: { _controller: FormLoginBundle:Login:secure } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml b/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml index eba64e56bb..a3e9473727 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_resource_plus_path.yml @@ -1,3 +1,3 @@ blog_show: resource: validpattern.yml - pattern: /test + path: /test diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml b/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml index 3b4c76898b..547cda3b61 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/nonesense_type_without_resource.yml @@ -1,3 +1,3 @@ blog_show: - pattern: /blog/{slug} + path: /blog/{slug} type: custom diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml b/src/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml index 1009741a86..78be239aa4 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/special_route_name.yml @@ -1,2 +1,2 @@ "#$péß^a|": - pattern: "true" + path: "true" diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php index 08e7d6e347..9841458a63 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.php @@ -6,9 +6,18 @@ $collection = new RouteCollection(); $collection->add('blog_show', new Route( '/blog/{slug}', array('_controller' => 'MyBlogBundle:Blog:show'), - array('_method' => 'GET', 'locale' => '\w+'), + array('_method' => 'GET', 'locale' => '\w+', '_scheme' => 'https'), array('compiler_class' => 'RouteCompiler'), '{locale}.example.com' )); +$collection->add('blog_show_legacy', new Route( + '/blog/{slug}', + array('_controller' => 'MyBlogBundle:Blog:show'), + array('locale' => '\w+'), + array('compiler_class' => 'RouteCompiler'), + '{locale}.example.com', + array('https'), + array('GET') +)); return $collection; diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml index eb3aea78b6..df3a256acf 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.xml @@ -4,9 +4,16 @@ 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+ + + + + MyBundle:Blog:show GET + https \w+ diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml index d78a3e44e7..419923e9c3 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml @@ -1,7 +1,17 @@ blog_show: - pattern: /blog/{slug} + path: /blog/{slug} defaults: { _controller: MyBlogBundle:Blog:show } - host : "{locale}.example.com" - requirements: { '_method': 'GET', 'locale': '\w+' } + host: "{locale}.example.com" + requirements: { 'locale': '\w+' } + methods: ['GET'] + schemes: ['https'] + options: + compiler_class: RouteCompiler + +blog_show_legacy: + pattern: /blog/{slug} + defaults: { _controller: MyBlogBundle:Blog:show } + host: "{locale}.example.com" + requirements: { '_method': 'GET', 'locale': '\w+', _scheme: 'https' } options: compiler_class: RouteCompiler diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php index 6cb2456852..7494fb01d9 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php @@ -40,13 +40,16 @@ class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase $routeCollection = $loader->load('validpattern.php'); $routes = $routeCollection->all(); - $this->assertEquals(1, count($routes), 'One route is loaded'); + $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('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertEquals('GET', $route->getRequirement('_method')); - $this->assertEquals('{locale}.example.com', $route->getHost()); - $this->assertEquals('RouteCompiler', $route->getOption('compiler_class')); + + 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')); + } } } diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php index e40468247d..b67ebf3486 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php @@ -41,12 +41,13 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $routeCollection = $loader->load('validpattern.xml'); $routes = $routeCollection->all(); - $this->assertEquals(1, count($routes), 'One route is loaded'); + $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')); @@ -57,7 +58,8 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures'))); $routeCollection = $loader->load('namespaceprefix.xml'); - $this->assertCount(1, $routeCollection, 'One route is loaded'); + $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')); @@ -73,14 +75,17 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $routeCollection = $loader->load('validresource.xml'); $routes = $routeCollection->all(); - $this->assertEquals(1, count($routes), 'One route is loaded'); + $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('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()); + + 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()); + } } /** diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php index bb055de4e7..b6234bf8e5 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php @@ -79,15 +79,18 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $routeCollection = $loader->load('validpattern.yml'); $routes = $routeCollection->all(); - $this->assertEquals(1, count($routes), 'One route is loaded'); + $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('MyBlogBundle:Blog:show', $route->getDefault('_controller')); - $this->assertEquals('GET', $route->getRequirement('_method')); - $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->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')); + } } public function testLoadWithResource() @@ -96,7 +99,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase $routeCollection = $loader->load('validresource.yml'); $routes = $routeCollection->all(); - $this->assertEquals(1, count($routes), 'One route is loaded'); + $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'));