diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.yml b/src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.yml
index cb71ec3b75b79..c4f41c6c8637f 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.yml
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.yml
@@ -1,3 +1,6 @@
+_subroutines:
+ number: \d
+
app_homepage:
path: /
controller: AppBundle:Homepage:show
diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php b/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php
index 0b8fa0a9eb339..b017ebda2a6da 100644
--- a/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php
+++ b/src/Symfony/Component/Routing/Tests/Fixtures/php_dsl.php
@@ -3,6 +3,8 @@
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
+ $routes->subroutine('number', '\d');
+
$routes
->collection()
->add('foo', '/foo')
diff --git a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
index c0a72b6f81cbe..1d5ffb858296b 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/PhpFileLoaderTest.php
@@ -113,6 +113,7 @@ public function testRoutingConfigurator()
->setMethods(array('GET'))
->setDefaults(array('id' => 0))
);
+ $expectedCollection->setSubroutine('number', '\d');
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub.php')));
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl.php')));
diff --git a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
index 0b2e1a9d79340..c1f00a33fc222 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/XmlFileLoaderTest.php
@@ -411,4 +411,12 @@ public function testImportRouteWithNamePrefix()
$this->assertNotNull($routeCollection->get('api_app_blog'));
$this->assertEquals('/api/blog', $routeCollection->get('api_app_blog')->getPath());
}
+
+ public function testSubroutine()
+ {
+ $loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
+ $routeCollection = $loader->load('routing.xml');
+
+ $this->assertSame(array('number' => '\d'), $routeCollection->getSubroutines());
+ }
}
diff --git a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
index 3bcfe1b5b6453..97bb3feb28408 100644
--- a/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Routing/Tests/Loader/YamlFileLoaderTest.php
@@ -275,4 +275,12 @@ public function testImportingWithControllerDefault()
$this->assertEquals('DefaultController::defaultAction', $routes->get('home.nl')->getDefault('_controller'));
$this->assertEquals('DefaultController::defaultAction', $routes->get('not_localized')->getDefault('_controller'));
}
+
+ public function testSubroutine()
+ {
+ $loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
+ $routeCollection = $loader->load('routing.yml');
+
+ $this->assertSame(array('number' => '\d'), $routeCollection->getSubroutines());
+ }
}
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
index cf7ded2551cf2..eb9312b6049eb 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php
@@ -596,6 +596,16 @@ public function testRequirementWithCapturingGroup()
$this->assertEquals(array('_route' => 'a', 'a' => 'a', 'b' => 'b'), $matcher->match('/a/b'));
}
+ public function testSubroutine()
+ {
+ $coll = new RouteCollection();
+ $coll->setSubroutine('date', '\d{4}-\d{2}-\d{2}');
+ $coll->add('a', new Route('/{a}', array(), array('a' => '(?&date)')));
+
+ $matcher = $this->getUrlMatcher($coll);
+ $this->assertEquals(array('_route' => 'a', 'a' => '2018-03-14'), $matcher->match('/2018-03-14'));
+ }
+
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
{
return new UrlMatcher($routes, $context ?: new RequestContext());
diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
index 76a042d670b29..7fa1209ae4f7c 100644
--- a/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteCollectionBuilderTest.php
@@ -361,4 +361,13 @@ public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections()
$this->assertEquals('/other/a', $routes['a']->getPath());
$this->assertEquals('/other/b', $routes['b']->getPath());
}
+
+ public function testSubroutine()
+ {
+ $routeCollectionBuilder = new RouteCollectionBuilder(new YamlFileLoader(new FileLocator(array(__DIR__.'/Fixtures/controller'))));
+ $routeCollectionBuilder->import('routing.yml');
+ $routeCollection = $routeCollectionBuilder->build();
+
+ $this->assertSame(array('number' => '\d'), $routeCollection->getSubroutines());
+ }
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy