composer update

This commit is contained in:
2019-06-23 10:14:30 +00:00
parent a56db5ea2b
commit ec4506ebf4
790 changed files with 35767 additions and 7663 deletions

View File

@@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
class EncodingClass
{
public function routeÀction()
{
}
}

View File

@@ -0,0 +1,34 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/defaults", locale="g_locale", format="g_format")
*/
class GlobalDefaultsClass
{
/**
* @Route("/specific-locale", name="specific_locale", locale="s_locale")
*/
public function locale()
{
}
/**
* @Route("/specific-format", name="specific_format", format="s_format")
*/
public function format()
{
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/test", utf8=true)
*/
class Utf8ActionControllers
{
/**
* @Route(name="one")
*/
public function one()
{
}
/**
* @Route(name="two", utf8=false)
*/
public function two()
{
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes->add('defaults', '/defaults')
->locale('en')
->format('html')
;
};

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<route id="defaults" path="/defaults" locale="en" format="html" />
</routes>

View File

@@ -0,0 +1,4 @@
defaults:
path: /defaults
locale: en
format: html

View File

@@ -0,0 +1,17 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
],
[ // $regexpList
],
[ // $dynamicRoutes
],
null, // $checkCondition
];

View File

@@ -0,0 +1,108 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
true, // $matchHost
[ // $staticRoutes
'/test/baz' => [[['_route' => 'baz'], null, null, null, false, false, null]],
'/test/baz.html' => [[['_route' => 'baz2'], null, null, null, false, false, null]],
'/test/baz3' => [[['_route' => 'baz3'], null, null, null, true, false, null]],
'/foofoo' => [[['_route' => 'foofoo', 'def' => 'test'], null, null, null, false, false, null]],
'/spa ce' => [[['_route' => 'space'], null, null, null, false, false, null]],
'/multi/new' => [[['_route' => 'overridden2'], null, null, null, false, false, null]],
'/multi/hey' => [[['_route' => 'hey'], null, null, null, true, false, null]],
'/ababa' => [[['_route' => 'ababa'], null, null, null, false, false, null]],
'/route1' => [[['_route' => 'route1'], 'a.example.com', null, null, false, false, null]],
'/c2/route2' => [[['_route' => 'route2'], 'a.example.com', null, null, false, false, null]],
'/route4' => [[['_route' => 'route4'], 'a.example.com', null, null, false, false, null]],
'/c2/route3' => [[['_route' => 'route3'], 'b.example.com', null, null, false, false, null]],
'/route5' => [[['_route' => 'route5'], 'c.example.com', null, null, false, false, null]],
'/route6' => [[['_route' => 'route6'], null, null, null, false, false, null]],
'/route11' => [[['_route' => 'route11'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
'/route12' => [[['_route' => 'route12', 'var1' => 'val'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
'/route17' => [[['_route' => 'route17'], null, null, null, false, false, null]],
],
[ // $regexpList
0 => '{^(?'
.'|(?:(?:[^./]*+\\.)++)(?'
.'|/foo/(baz|symfony)(*:47)'
.'|/bar(?'
.'|/([^/]++)(*:70)'
.'|head/([^/]++)(*:90)'
.')'
.'|/test/([^/]++)(?'
.'|(*:115)'
.')'
.'|/([\']+)(*:131)'
.'|/a/(?'
.'|b\'b/([^/]++)(?'
.'|(*:160)'
.'|(*:168)'
.')'
.'|(.*)(*:181)'
.'|b\'b/([^/]++)(?'
.'|(*:204)'
.'|(*:212)'
.')'
.')'
.'|/multi/hello(?:/([^/]++))?(*:248)'
.'|/([^/]++)/b/([^/]++)(?'
.'|(*:279)'
.'|(*:287)'
.')'
.'|/aba/([^/]++)(*:309)'
.')|(?i:([^\\.]++)\\.example\\.com)\\.(?'
.'|/route1(?'
.'|3/([^/]++)(*:371)'
.'|4/([^/]++)(*:389)'
.')'
.')|(?i:c\\.example\\.com)\\.(?'
.'|/route15/([^/]++)(*:441)'
.')|(?:(?:[^./]*+\\.)++)(?'
.'|/route16/([^/]++)(*:489)'
.'|/a/(?'
.'|a\\.\\.\\.(*:510)'
.'|b/(?'
.'|([^/]++)(*:531)'
.'|c/([^/]++)(*:549)'
.')'
.')'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
47 => [[['_route' => 'foo', 'def' => 'test'], ['bar'], null, null, false, true, null]],
70 => [[['_route' => 'bar'], ['foo'], ['GET' => 0, 'HEAD' => 1], null, false, true, null]],
90 => [[['_route' => 'barhead'], ['foo'], ['GET' => 0], null, false, true, null]],
115 => [
[['_route' => 'baz4'], ['foo'], null, null, true, true, null],
[['_route' => 'baz5'], ['foo'], ['POST' => 0], null, true, true, null],
[['_route' => 'baz.baz6'], ['foo'], ['PUT' => 0], null, true, true, null],
],
131 => [[['_route' => 'quoter'], ['quoter'], null, null, false, true, null]],
160 => [[['_route' => 'foo1'], ['foo'], ['PUT' => 0], null, false, true, null]],
168 => [[['_route' => 'bar1'], ['bar'], null, null, false, true, null]],
181 => [[['_route' => 'overridden'], ['var'], null, null, false, true, null]],
204 => [[['_route' => 'foo2'], ['foo1'], null, null, false, true, null]],
212 => [[['_route' => 'bar2'], ['bar1'], null, null, false, true, null]],
248 => [[['_route' => 'helloWorld', 'who' => 'World!'], ['who'], null, null, false, true, null]],
279 => [[['_route' => 'foo3'], ['_locale', 'foo'], null, null, false, true, null]],
287 => [[['_route' => 'bar3'], ['_locale', 'bar'], null, null, false, true, null]],
309 => [[['_route' => 'foo4'], ['foo'], null, null, false, true, null]],
371 => [[['_route' => 'route13'], ['var1', 'name'], null, null, false, true, null]],
389 => [[['_route' => 'route14', 'var1' => 'val'], ['var1', 'name'], null, null, false, true, null]],
441 => [[['_route' => 'route15'], ['name'], null, null, false, true, null]],
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
549 => [
[['_route' => 'c'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
],
[ // $regexpList
0 => '{^(?'
.'|/(en|fr)/(?'
.'|admin/post(?'
.'|(*:32)'
.'|/(?'
.'|new(*:46)'
.'|(\\d+)(*:58)'
.'|(\\d+)/edit(*:75)'
.'|(\\d+)/delete(*:94)'
.')'
.')'
.'|blog(?'
.'|(*:110)'
.'|/(?'
.'|rss\\.xml(*:130)'
.'|p(?'
.'|age/([^/]++)(*:154)'
.'|osts/([^/]++)(*:175)'
.')'
.'|comments/(\\d+)/new(*:202)'
.'|search(*:216)'
.')'
.')'
.'|log(?'
.'|in(*:234)'
.'|out(*:245)'
.')'
.')'
.'|/(en|fr)?(*:264)'
.')/?$}sD',
],
[ // $dynamicRoutes
32 => [[['_route' => 'a', '_locale' => 'en'], ['_locale'], null, null, true, false, null]],
46 => [[['_route' => 'b', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
58 => [[['_route' => 'c', '_locale' => 'en'], ['_locale', 'id'], null, null, false, true, null]],
75 => [[['_route' => 'd', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
94 => [[['_route' => 'e', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
110 => [[['_route' => 'f', '_locale' => 'en'], ['_locale'], null, null, true, false, null]],
130 => [[['_route' => 'g', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
154 => [[['_route' => 'h', '_locale' => 'en'], ['_locale', 'page'], null, null, false, true, null]],
175 => [[['_route' => 'i', '_locale' => 'en'], ['_locale', 'page'], null, null, false, true, null]],
202 => [[['_route' => 'j', '_locale' => 'en'], ['_locale', 'id'], null, null, false, false, null]],
216 => [[['_route' => 'k', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
234 => [[['_route' => 'l', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
245 => [[['_route' => 'm', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
264 => [
[['_route' => 'n', '_locale' => 'en'], ['_locale'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,44 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
],
[ // $regexpList
0 => '{^(?'
.'|/abc([^/]++)/(?'
.'|1(?'
.'|(*:27)'
.'|0(?'
.'|(*:38)'
.'|0(*:46)'
.')'
.')'
.'|2(?'
.'|(*:59)'
.'|0(?'
.'|(*:70)'
.'|0(*:78)'
.')'
.')'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
27 => [[['_route' => 'r1'], ['foo'], null, null, false, false, null]],
38 => [[['_route' => 'r10'], ['foo'], null, null, false, false, null]],
46 => [[['_route' => 'r100'], ['foo'], null, null, false, false, null]],
59 => [[['_route' => 'r2'], ['foo'], null, null, false, false, null]],
70 => [[['_route' => 'r20'], ['foo'], null, null, false, false, null]],
78 => [
[['_route' => 'r200'], ['foo'], null, null, false, false, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,29 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
true, // $matchHost
[ // $staticRoutes
],
[ // $regexpList
0 => '{^(?'
.'|(?i:([^\\.]++)\\.exampple\\.com)\\.(?'
.'|/abc([^/]++)(?'
.'|(*:56)'
.')'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
56 => [
[['_route' => 'r1'], ['foo', 'foo'], null, null, false, true, null],
[['_route' => 'r2'], ['foo', 'foo'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,110 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
true, // $matchHost
[ // $staticRoutes
'/test/baz' => [[['_route' => 'baz'], null, null, null, false, false, null]],
'/test/baz.html' => [[['_route' => 'baz2'], null, null, null, false, false, null]],
'/test/baz3' => [[['_route' => 'baz3'], null, null, null, true, false, null]],
'/foofoo' => [[['_route' => 'foofoo', 'def' => 'test'], null, null, null, false, false, null]],
'/spa ce' => [[['_route' => 'space'], null, null, null, false, false, null]],
'/multi/new' => [[['_route' => 'overridden2'], null, null, null, false, false, null]],
'/multi/hey' => [[['_route' => 'hey'], null, null, null, true, false, null]],
'/ababa' => [[['_route' => 'ababa'], null, null, null, false, false, null]],
'/route1' => [[['_route' => 'route1'], 'a.example.com', null, null, false, false, null]],
'/c2/route2' => [[['_route' => 'route2'], 'a.example.com', null, null, false, false, null]],
'/route4' => [[['_route' => 'route4'], 'a.example.com', null, null, false, false, null]],
'/c2/route3' => [[['_route' => 'route3'], 'b.example.com', null, null, false, false, null]],
'/route5' => [[['_route' => 'route5'], 'c.example.com', null, null, false, false, null]],
'/route6' => [[['_route' => 'route6'], null, null, null, false, false, null]],
'/route11' => [[['_route' => 'route11'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
'/route12' => [[['_route' => 'route12', 'var1' => 'val'], '#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', null, null, false, false, null]],
'/route17' => [[['_route' => 'route17'], null, null, null, false, false, null]],
'/secure' => [[['_route' => 'secure'], null, null, ['https' => 0], false, false, null]],
'/nonsecure' => [[['_route' => 'nonsecure'], null, null, ['http' => 0], false, false, null]],
],
[ // $regexpList
0 => '{^(?'
.'|(?:(?:[^./]*+\\.)++)(?'
.'|/foo/(baz|symfony)(*:47)'
.'|/bar(?'
.'|/([^/]++)(*:70)'
.'|head/([^/]++)(*:90)'
.')'
.'|/test/([^/]++)(?'
.'|(*:115)'
.')'
.'|/([\']+)(*:131)'
.'|/a/(?'
.'|b\'b/([^/]++)(?'
.'|(*:160)'
.'|(*:168)'
.')'
.'|(.*)(*:181)'
.'|b\'b/([^/]++)(?'
.'|(*:204)'
.'|(*:212)'
.')'
.')'
.'|/multi/hello(?:/([^/]++))?(*:248)'
.'|/([^/]++)/b/([^/]++)(?'
.'|(*:279)'
.'|(*:287)'
.')'
.'|/aba/([^/]++)(*:309)'
.')|(?i:([^\\.]++)\\.example\\.com)\\.(?'
.'|/route1(?'
.'|3/([^/]++)(*:371)'
.'|4/([^/]++)(*:389)'
.')'
.')|(?i:c\\.example\\.com)\\.(?'
.'|/route15/([^/]++)(*:441)'
.')|(?:(?:[^./]*+\\.)++)(?'
.'|/route16/([^/]++)(*:489)'
.'|/a/(?'
.'|a\\.\\.\\.(*:510)'
.'|b/(?'
.'|([^/]++)(*:531)'
.'|c/([^/]++)(*:549)'
.')'
.')'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
47 => [[['_route' => 'foo', 'def' => 'test'], ['bar'], null, null, false, true, null]],
70 => [[['_route' => 'bar'], ['foo'], ['GET' => 0, 'HEAD' => 1], null, false, true, null]],
90 => [[['_route' => 'barhead'], ['foo'], ['GET' => 0], null, false, true, null]],
115 => [
[['_route' => 'baz4'], ['foo'], null, null, true, true, null],
[['_route' => 'baz5'], ['foo'], ['POST' => 0], null, true, true, null],
[['_route' => 'baz.baz6'], ['foo'], ['PUT' => 0], null, true, true, null],
],
131 => [[['_route' => 'quoter'], ['quoter'], null, null, false, true, null]],
160 => [[['_route' => 'foo1'], ['foo'], ['PUT' => 0], null, false, true, null]],
168 => [[['_route' => 'bar1'], ['bar'], null, null, false, true, null]],
181 => [[['_route' => 'overridden'], ['var'], null, null, false, true, null]],
204 => [[['_route' => 'foo2'], ['foo1'], null, null, false, true, null]],
212 => [[['_route' => 'bar2'], ['bar1'], null, null, false, true, null]],
248 => [[['_route' => 'helloWorld', 'who' => 'World!'], ['who'], null, null, false, true, null]],
279 => [[['_route' => 'foo3'], ['_locale', 'foo'], null, null, false, true, null]],
287 => [[['_route' => 'bar3'], ['_locale', 'bar'], null, null, false, true, null]],
309 => [[['_route' => 'foo4'], ['foo'], null, null, false, true, null]],
371 => [[['_route' => 'route13'], ['var1', 'name'], null, null, false, true, null]],
389 => [[['_route' => 'route14', 'var1' => 'val'], ['var1', 'name'], null, null, false, true, null]],
441 => [[['_route' => 'route15'], ['name'], null, null, false, true, null]],
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
549 => [
[['_route' => 'c'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,30 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
'/rootprefix/test' => [[['_route' => 'static'], null, null, null, false, false, null]],
'/with-condition' => [[['_route' => 'with-condition'], null, null, null, false, false, -1]],
],
[ // $regexpList
0 => '{^(?'
.'|/rootprefix/([^/]++)(*:27)'
.')/?$}sD',
],
[ // $dynamicRoutes
27 => [
[['_route' => 'dynamic'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
static function ($condition, $context, $request) { // $checkCondition
switch ($condition) {
case -1: return ($context->getMethod() == "GET");
}
},
];

View File

@@ -0,0 +1,25 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
'/just_head' => [[['_route' => 'just_head'], null, ['HEAD' => 0], null, false, false, null]],
'/head_and_get' => [[['_route' => 'head_and_get'], null, ['HEAD' => 0, 'GET' => 1], null, false, false, null]],
'/get_and_head' => [[['_route' => 'get_and_head'], null, ['GET' => 0, 'HEAD' => 1], null, false, false, null]],
'/post_and_head' => [[['_route' => 'post_and_head'], null, ['POST' => 0, 'HEAD' => 1], null, false, false, null]],
'/put_and_post' => [
[['_route' => 'put_and_post'], null, ['PUT' => 0, 'POST' => 1], null, false, false, null],
[['_route' => 'put_and_get_and_head'], null, ['PUT' => 0, 'GET' => 1, 'HEAD' => 2], null, false, false, null],
],
],
[ // $regexpList
],
[ // $dynamicRoutes
],
null, // $checkCondition
];

View File

@@ -0,0 +1,38 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
'/a/11' => [[['_route' => 'a_first'], null, null, null, false, false, null]],
'/a/22' => [[['_route' => 'a_second'], null, null, null, false, false, null]],
'/a/333' => [[['_route' => 'a_third'], null, null, null, false, false, null]],
'/a/44' => [[['_route' => 'a_fourth'], null, null, null, true, false, null]],
'/a/55' => [[['_route' => 'a_fifth'], null, null, null, true, false, null]],
'/a/66' => [[['_route' => 'a_sixth'], null, null, null, true, false, null]],
'/nested/group/a' => [[['_route' => 'nested_a'], null, null, null, true, false, null]],
'/nested/group/b' => [[['_route' => 'nested_b'], null, null, null, true, false, null]],
'/nested/group/c' => [[['_route' => 'nested_c'], null, null, null, true, false, null]],
'/slashed/group' => [[['_route' => 'slashed_a'], null, null, null, true, false, null]],
'/slashed/group/b' => [[['_route' => 'slashed_b'], null, null, null, true, false, null]],
'/slashed/group/c' => [[['_route' => 'slashed_c'], null, null, null, true, false, null]],
],
[ // $regexpList
0 => '{^(?'
.'|/([^/]++)(*:16)'
.'|/nested/([^/]++)(*:39)'
.')/?$}sD',
],
[ // $dynamicRoutes
16 => [[['_route' => 'a_wildcard'], ['param'], null, null, false, true, null]],
39 => [
[['_route' => 'nested_wildcard'], ['param'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,50 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
'/trailing/simple/no-methods' => [[['_route' => 'simple_trailing_slash_no_methods'], null, null, null, true, false, null]],
'/trailing/simple/get-method' => [[['_route' => 'simple_trailing_slash_GET_method'], null, ['GET' => 0], null, true, false, null]],
'/trailing/simple/head-method' => [[['_route' => 'simple_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, true, false, null]],
'/trailing/simple/post-method' => [[['_route' => 'simple_trailing_slash_POST_method'], null, ['POST' => 0], null, true, false, null]],
'/not-trailing/simple/no-methods' => [[['_route' => 'simple_not_trailing_slash_no_methods'], null, null, null, false, false, null]],
'/not-trailing/simple/get-method' => [[['_route' => 'simple_not_trailing_slash_GET_method'], null, ['GET' => 0], null, false, false, null]],
'/not-trailing/simple/head-method' => [[['_route' => 'simple_not_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, false, false, null]],
'/not-trailing/simple/post-method' => [[['_route' => 'simple_not_trailing_slash_POST_method'], null, ['POST' => 0], null, false, false, null]],
],
[ // $regexpList
0 => '{^(?'
.'|/trailing/regex/(?'
.'|no\\-methods/([^/]++)(*:46)'
.'|get\\-method/([^/]++)(*:73)'
.'|head\\-method/([^/]++)(*:101)'
.'|post\\-method/([^/]++)(*:130)'
.')'
.'|/not\\-trailing/regex/(?'
.'|no\\-methods/([^/]++)(*:183)'
.'|get\\-method/([^/]++)(*:211)'
.'|head\\-method/([^/]++)(*:240)'
.'|post\\-method/([^/]++)(*:269)'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
46 => [[['_route' => 'regex_trailing_slash_no_methods'], ['param'], null, null, true, true, null]],
73 => [[['_route' => 'regex_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, true, true, null]],
101 => [[['_route' => 'regex_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, true, true, null]],
130 => [[['_route' => 'regex_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, true, true, null]],
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
269 => [
[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,50 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
'/trailing/simple/no-methods' => [[['_route' => 'simple_trailing_slash_no_methods'], null, null, null, true, false, null]],
'/trailing/simple/get-method' => [[['_route' => 'simple_trailing_slash_GET_method'], null, ['GET' => 0], null, true, false, null]],
'/trailing/simple/head-method' => [[['_route' => 'simple_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, true, false, null]],
'/trailing/simple/post-method' => [[['_route' => 'simple_trailing_slash_POST_method'], null, ['POST' => 0], null, true, false, null]],
'/not-trailing/simple/no-methods' => [[['_route' => 'simple_not_trailing_slash_no_methods'], null, null, null, false, false, null]],
'/not-trailing/simple/get-method' => [[['_route' => 'simple_not_trailing_slash_GET_method'], null, ['GET' => 0], null, false, false, null]],
'/not-trailing/simple/head-method' => [[['_route' => 'simple_not_trailing_slash_HEAD_method'], null, ['HEAD' => 0], null, false, false, null]],
'/not-trailing/simple/post-method' => [[['_route' => 'simple_not_trailing_slash_POST_method'], null, ['POST' => 0], null, false, false, null]],
],
[ // $regexpList
0 => '{^(?'
.'|/trailing/regex/(?'
.'|no\\-methods/([^/]++)(*:46)'
.'|get\\-method/([^/]++)(*:73)'
.'|head\\-method/([^/]++)(*:101)'
.'|post\\-method/([^/]++)(*:130)'
.')'
.'|/not\\-trailing/regex/(?'
.'|no\\-methods/([^/]++)(*:183)'
.'|get\\-method/([^/]++)(*:211)'
.'|head\\-method/([^/]++)(*:240)'
.'|post\\-method/([^/]++)(*:269)'
.')'
.')/?$}sD',
],
[ // $dynamicRoutes
46 => [[['_route' => 'regex_trailing_slash_no_methods'], ['param'], null, null, true, true, null]],
73 => [[['_route' => 'regex_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, true, true, null]],
101 => [[['_route' => 'regex_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, true, true, null]],
130 => [[['_route' => 'regex_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, true, true, null]],
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
269 => [
[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,32 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
false, // $matchHost
[ // $staticRoutes
],
[ // $regexpList
0 => '{^(?'
.'|/(a)(*:11)'
.')/?$}sD',
11 => '{^(?'
.'|/(.)(*:22)'
.')/?$}sDu',
22 => '{^(?'
.'|/(.)(*:33)'
.')/?$}sD',
],
[ // $dynamicRoutes
11 => [[['_route' => 'a'], ['a'], null, null, false, true, null]],
22 => [[['_route' => 'b'], ['a'], null, null, false, true, null]],
33 => [
[['_route' => 'c'], ['a'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
],
null, // $checkCondition
];

View File

@@ -0,0 +1,22 @@
<?php
/**
* This file has been auto-generated
* by the Symfony Routing Component.
*/
return [
true, // $matchHost
[ // $staticRoutes
'/' => [
[['_route' => 'a'], '#^(?P<d>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null],
[['_route' => 'c'], '#^(?P<e>[^\\.]++)\\.e\\.c\\.b\\.a$#sDi', null, null, false, false, null],
[['_route' => 'b'], 'd.c.b.a', null, null, false, false, null],
],
],
[ // $regexpList
],
[ // $dynamicRoutes
],
null, // $checkCondition
];

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -107,7 +107,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
549 => [[['_route' => 'c'], ['var'], null, null, false, true, null]],
549 => [
[['_route' => 'c'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -2770,7 +2770,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
49567 => [[['_route' => '_974'], ['a', 'b', 'c'], null, null, false, false, null]],
49620 => [[['_route' => '_835'], ['a', 'b', 'c'], null, null, false, false, null]],
49668 => [[['_route' => '_934'], ['a', 'b', 'c'], null, null, false, false, null]],
49718 => [[['_route' => '_869'], ['a', 'b', 'c'], null, null, false, false, null]],
49718 => [
[['_route' => '_869'], ['a', 'b', 'c'], null, null, false, false, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -60,7 +60,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
216 => [[['_route' => 'k', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
234 => [[['_route' => 'l', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
245 => [[['_route' => 'm', '_locale' => 'en'], ['_locale'], null, null, false, false, null]],
264 => [[['_route' => 'n', '_locale' => 'en'], ['_locale'], null, null, false, true, null]],
264 => [
[['_route' => 'n', '_locale' => 'en'], ['_locale'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -40,7 +40,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
46 => [[['_route' => 'r100'], ['foo'], null, null, false, false, null]],
59 => [[['_route' => 'r2'], ['foo'], null, null, false, false, null]],
70 => [[['_route' => 'r20'], ['foo'], null, null, false, false, null]],
78 => [[['_route' => 'r200'], ['foo'], null, null, false, false, null]],
78 => [
[['_route' => 'r200'], ['foo'], null, null, false, false, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -28,6 +28,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
56 => [
[['_route' => 'r1'], ['foo', 'foo'], null, null, false, true, null],
[['_route' => 'r2'], ['foo', 'foo'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -109,7 +109,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
489 => [[['_route' => 'route16', 'var1' => 'val'], ['name'], null, null, false, true, null]],
510 => [[['_route' => 'a'], [], null, null, false, false, null]],
531 => [[['_route' => 'b'], ['var'], null, null, false, true, null]],
549 => [[['_route' => 'c'], ['var'], null, null, false, true, null]],
549 => [
[['_route' => 'c'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -24,7 +24,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
.')/?$}sD',
];
$this->dynamicRoutes = [
27 => [[['_route' => 'dynamic'], ['var'], null, null, false, true, null]],
27 => [
[['_route' => 'dynamic'], ['var'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
$this->checkCondition = static function ($condition, $context, $request) {
switch ($condition) {

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -36,7 +36,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
];
$this->dynamicRoutes = [
16 => [[['_route' => 'a_wildcard'], ['param'], null, null, false, true, null]],
39 => [[['_route' => 'nested_wildcard'], ['param'], null, null, false, true, null]],
39 => [
[['_route' => 'nested_wildcard'], ['param'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -48,7 +48,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
269 => [[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null]],
269 => [
[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -48,7 +48,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
183 => [[['_route' => 'regex_not_trailing_slash_no_methods'], ['param'], null, null, false, true, null]],
211 => [[['_route' => 'regex_not_trailing_slash_GET_method'], ['param'], ['GET' => 0], null, false, true, null]],
240 => [[['_route' => 'regex_not_trailing_slash_HEAD_method'], ['param'], ['HEAD' => 0], null, false, true, null]],
269 => [[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null]],
269 => [
[['_route' => 'regex_not_trailing_slash_POST_method'], ['param'], ['POST' => 0], null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{
@@ -28,7 +28,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
$this->dynamicRoutes = [
11 => [[['_route' => 'a'], ['a'], null, null, false, true, null]],
22 => [[['_route' => 'b'], ['a'], null, null, false, true, null]],
33 => [[['_route' => 'c'], ['a'], null, null, false, true, null]],
33 => [
[['_route' => 'c'], ['a'], null, null, false, true, null],
[null, null, null, null, false, false, 0],
],
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherTrait;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherTrait;
use Symfony\Component\Routing\RequestContext;
/**
@@ -9,7 +9,7 @@ use Symfony\Component\Routing\RequestContext;
*/
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
{
use PhpMatcherTrait;
use CompiledUrlMatcherTrait;
public function __construct(RequestContext $context)
{

View File

@@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes
->add('one', '/one')
->add('two', '/two')->defaults(['specific' => 'imported'])
;
};

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<route id="one" path="/one" />
<route id="two" path="/two">
<default key="specific">imported</default>
</route>
</routes>

View File

@@ -0,0 +1,7 @@
one:
path: /one
two:
path: /two
defaults:
specific: imported

View File

@@ -0,0 +1,11 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes->import('imported-with-defaults.php')
->prefix('/defaults')
->locale('g_locale')
->format('g_format')
;
};

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="imported-with-defaults.xml" prefix="/defaults"
locale="g_locale"
format="g_format" />
</routes>

View File

@@ -0,0 +1,5 @@
defaults:
resource: imported-with-defaults.yml
prefix: /defaults
locale: g_locale
format: g_format

View File

@@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes
->add('utf8_one', '/one')
->add('utf8_two', '/two')
;
};

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing">
<route id="utf8_one" path="/one" />
<route id="utf8_two" path="/two" />
</routes>

View File

@@ -0,0 +1,5 @@
utf8_one:
path: /one
utf8_two:
path: /two

View File

@@ -0,0 +1,7 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes->import('imported-with-utf8.php')->utf8();
};

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
https://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="imported-with-utf8.xml" utf8="true" />
</routes>

View File

@@ -0,0 +1,3 @@
utf8_routes:
resource: imported-with-utf8.yml
utf8: true

View File

@@ -0,0 +1,10 @@
<?php
namespace Symfony\Component\Routing\Loader\Configurator;
return function (RoutingConfigurator $routes) {
$routes
->add('some_route', '/')
->add('some_utf8_route', '/utf8')->utf8()
;
};

View File

@@ -0,0 +1,6 @@
some_route:
path: /
some_utf8_route:
path: /utf8
utf8: true

View File

@@ -0,0 +1,240 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Generator\CompiledUrlGenerator;
use Symfony\Component\Routing\Generator\Dumper\CompiledUrlGeneratorDumper;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class CompiledUrlGeneratorDumperTest extends TestCase
{
/**
* @var RouteCollection
*/
private $routeCollection;
/**
* @var CompiledUrlGeneratorDumper
*/
private $generatorDumper;
/**
* @var string
*/
private $testTmpFilepath;
/**
* @var string
*/
private $largeTestTmpFilepath;
protected function setUp()
{
parent::setUp();
$this->routeCollection = new RouteCollection();
$this->generatorDumper = new CompiledUrlGeneratorDumper($this->routeCollection);
$this->testTmpFilepath = sys_get_temp_dir().'/php_generator.'.$this->getName().'.php';
$this->largeTestTmpFilepath = sys_get_temp_dir().'/php_generator.'.$this->getName().'.large.php';
@unlink($this->testTmpFilepath);
@unlink($this->largeTestTmpFilepath);
}
protected function tearDown()
{
parent::tearDown();
@unlink($this->testTmpFilepath);
$this->routeCollection = null;
$this->generatorDumper = null;
$this->testTmpFilepath = null;
}
public function testDumpWithRoutes()
{
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
$this->routeCollection->add('Test2', new Route('/testing2'));
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'));
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_URL);
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_PATH);
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
}
public function testDumpWithSimpleLocalizedRoutes()
{
$this->routeCollection->add('test', (new Route('/foo')));
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test'));
$this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_locale', 'nl')->setDefault('_canonical_route', 'test'));
$code = $this->generatorDumper->dump();
file_put_contents($this->testTmpFilepath, $code);
$context = new RequestContext('/app.php');
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, $context, null, 'en');
$urlWithDefaultLocale = $projectUrlGenerator->generate('test');
$urlWithSpecifiedLocale = $projectUrlGenerator->generate('test', ['_locale' => 'nl']);
$context->setParameter('_locale', 'en');
$urlWithEnglishContext = $projectUrlGenerator->generate('test');
$context->setParameter('_locale', 'nl');
$urlWithDutchContext = $projectUrlGenerator->generate('test');
$this->assertEquals('/app.php/testing/is/fun', $urlWithDefaultLocale);
$this->assertEquals('/app.php/testen/is/leuk', $urlWithSpecifiedLocale);
$this->assertEquals('/app.php/testing/is/fun', $urlWithEnglishContext);
$this->assertEquals('/app.php/testen/is/leuk', $urlWithDutchContext);
// test with full route name
$this->assertEquals('/app.php/testing/is/fun', $projectUrlGenerator->generate('test.en'));
$context->setParameter('_locale', 'de_DE');
// test that it fall backs to another route when there is no matching localized route
$this->assertEquals('/app.php/foo', $projectUrlGenerator->generate('test'));
}
/**
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
* @expectedExceptionMessage Unable to generate a URL for the named route "test" as such route does not exist.
*/
public function testDumpWithRouteNotFoundLocalizedRoutes()
{
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_locale', 'en')->setDefault('_canonical_route', 'test'));
$code = $this->generatorDumper->dump();
file_put_contents($this->testTmpFilepath, $code);
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'), null, 'pl_PL');
$projectUrlGenerator->generate('test');
}
public function testDumpWithFallbackLocaleLocalizedRoutes()
{
$this->routeCollection->add('test.en', (new Route('/testing/is/fun'))->setDefault('_canonical_route', 'test'));
$this->routeCollection->add('test.nl', (new Route('/testen/is/leuk'))->setDefault('_canonical_route', 'test'));
$this->routeCollection->add('test.fr', (new Route('/tester/est/amusant'))->setDefault('_canonical_route', 'test'));
$code = $this->generatorDumper->dump();
file_put_contents($this->testTmpFilepath, $code);
$context = new RequestContext('/app.php');
$context->setParameter('_locale', 'en_GB');
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, $context, null, null);
// test with context _locale
$this->assertEquals('/app.php/testing/is/fun', $projectUrlGenerator->generate('test'));
// test with parameters _locale
$this->assertEquals('/app.php/testen/is/leuk', $projectUrlGenerator->generate('test', ['_locale' => 'nl_BE']));
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'), null, 'fr_CA');
// test with default locale
$this->assertEquals('/app.php/tester/est/amusant', $projectUrlGenerator->generate('test'));
}
public function testDumpWithTooManyRoutes()
{
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
for ($i = 0; $i < 32769; ++$i) {
$this->routeCollection->add('route_'.$i, new Route('/route_'.$i));
}
$this->routeCollection->add('Test2', new Route('/testing2'));
file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump());
$this->routeCollection = $this->generatorDumper = null;
$projectUrlGenerator = new CompiledUrlGenerator(require $this->largeTestTmpFilepath, new RequestContext('/app.php'));
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_URL);
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', [], UrlGeneratorInterface::ABSOLUTE_PATH);
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testDumpWithoutRoutes()
{
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'));
$projectUrlGenerator->generate('Test', []);
}
/**
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
*/
public function testGenerateNonExistingRoute()
{
$this->routeCollection->add('Test', new Route('/test'));
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
$url = $projectUrlGenerator->generate('NonExisting', []);
}
public function testDumpForRouteWithDefaults()
{
$this->routeCollection->add('Test', new Route('/testing/{foo}', ['foo' => 'bar']));
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());
$url = $projectUrlGenerator->generate('Test', []);
$this->assertEquals('/testing', $url);
}
public function testDumpWithSchemeRequirement()
{
$this->routeCollection->add('Test1', new Route('/testing', [], [], [], '', ['ftp', 'https']));
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php'));
$absoluteUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_URL);
$relativeUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_PATH);
$this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl);
$this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl);
$projectUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext('/app.php', 'GET', 'localhost', 'https'));
$absoluteUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_URL);
$relativeUrl = $projectUrlGenerator->generate('Test1', [], UrlGeneratorInterface::ABSOLUTE_PATH);
$this->assertEquals('https://localhost/app.php/testing', $absoluteUrl);
$this->assertEquals('/app.php/testing', $relativeUrl);
}
}

View File

@@ -18,6 +18,9 @@ use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* @group legacy
*/
class PhpGeneratorDumperTest extends TestCase
{
/**

View File

@@ -302,7 +302,7 @@ class UrlGeneratorTest extends TestCase
$routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));
$generator = $this->getGenerator($routes);
$generator->setStrictRequirements(false);
$this->assertNull($generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
$this->assertSame('', $generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
}
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
@@ -313,7 +313,7 @@ class UrlGeneratorTest extends TestCase
->method('error');
$generator = $this->getGenerator($routes, [], $logger);
$generator->setStrictRequirements(false);
$this->assertNull($generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
$this->assertSame('', $generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));
}
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
@@ -436,7 +436,7 @@ class UrlGeneratorTest extends TestCase
{
$expectedPath = '/app.php/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'
.'/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'
.'?query=%40%3A%5B%5D/%28%29%2A%27%22%20%2B%2C%3B-._~%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id';
.'?query=@:%5B%5D/%28%29*%27%22%20%2B,;-._~%26%24%3C%3E%7C%7B%7D%25%5C%5E%60!?foo%3Dbar%23id';
// This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986)
// and other special ASCII chars. These chars are tested as static text path, variable path and query param.
@@ -467,7 +467,7 @@ class UrlGeneratorTest extends TestCase
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
// and following optional variables like _format could never match.
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
$this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');
$generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);
}
@@ -496,6 +496,27 @@ class UrlGeneratorTest extends TestCase
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index', '_format' => 'mobile.html']));
}
public function testImportantVariable()
{
$routes = $this->getRoutes('test', (new Route('/{page}.{!_format}'))->addDefaults(['_format' => 'mobile.html']));
$generator = $this->getGenerator($routes);
$this->assertSame('/app.php/index.xml', $generator->generate('test', ['page' => 'index', '_format' => 'xml']));
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index', '_format' => 'mobile.html']));
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index']));
}
/**
* @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
*/
public function testImportantVariableWithNoDefault()
{
$routes = $this->getRoutes('test', new Route('/{page}.{!_format}'));
$generator = $this->getGenerator($routes);
$generator->generate('test', ['page' => 'index']);
}
/**
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
*/
@@ -567,7 +588,7 @@ class UrlGeneratorTest extends TestCase
$routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));
$generator = $this->getGenerator($routes);
$generator->setStrictRequirements(false);
$this->assertNull($generator->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH));
$this->assertSame('', $generator->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH));
}
public function testHostIsCaseInsensitive()

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\AbstractClassCon
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\ActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\DefaultValueController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\ExplicitLocalizedActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\GlobalDefaultsClass;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\InvokableController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\InvokableLocalizedController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\LocalizedActionPathController;
@@ -35,6 +36,7 @@ use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\PrefixedActionLo
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\PrefixedActionPathController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RequirementsWithoutPlaceholderNameController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\RouteWithPrefixController;
use Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures\Utf8ActionControllers;
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
{
@@ -159,6 +161,32 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$this->assertEquals('/the/path', $routes->get('post.en')->getPath());
}
public function testGlobalDefaultsRoutesLoadWithAnnotation()
{
$routes = $this->loader->load(GlobalDefaultsClass::class);
$this->assertCount(2, $routes);
$specificLocaleRoute = $routes->get('specific_locale');
$this->assertSame('/defaults/specific-locale', $specificLocaleRoute->getPath());
$this->assertSame('s_locale', $specificLocaleRoute->getDefault('_locale'));
$this->assertSame('g_format', $specificLocaleRoute->getDefault('_format'));
$specificFormatRoute = $routes->get('specific_format');
$this->assertSame('/defaults/specific-format', $specificFormatRoute->getPath());
$this->assertSame('g_locale', $specificFormatRoute->getDefault('_locale'));
$this->assertSame('s_format', $specificFormatRoute->getDefault('_format'));
}
public function testUtf8RoutesLoadWithAnnotation()
{
$routes = $this->loader->load(Utf8ActionControllers::class);
$this->assertCount(2, $routes);
$this->assertTrue($routes->get('one')->getOption('utf8'), 'The route must accept utf8');
$this->assertFalse($routes->get('two')->getOption('utf8'), 'The route must not accept utf8');
}
public function testRouteWithPathWithPrefix()
{
$routes = $this->loader->load(PrefixedActionPathController::class);
@@ -278,6 +306,34 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
$this->assertEquals('/nl/suffix', $routes->get('action.nl')->getPath());
}
/**
* @requires function mb_strtolower
*/
public function testDefaultRouteName()
{
$methodRouteData = [
'name' => null,
];
$reader = $this->getReader();
$reader
->expects($this->once())
->method('getMethodAnnotations')
->will($this->returnValue([new RouteAnnotation($methodRouteData)]))
;
$loader = new class($reader) extends AnnotationClassLoader {
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
{
}
};
$routeCollection = $loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass');
$defaultName = array_keys($routeCollection->all())[0];
$this->assertSame($defaultName, 'symfony_component_routing_tests_fixtures_annotatedclasses_encodingclass_routeàction');
}
public function testLoadingRouteWithPrefix()
{
$routes = $this->loader->load(RouteWithPrefixController::class);

View File

@@ -29,7 +29,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
public function testLoad()
{
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
$this->reader->expects($this->exactly(4))->method('getClassAnnotation');
$this->reader
->expects($this->any())
@@ -52,6 +52,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\EncodingClass',
]);
$this->reader

View File

@@ -70,7 +70,7 @@ class ObjectRouteLoaderTest extends TestCase
* @expectedException \InvalidArgumentException
* @dataProvider getBadResourceStrings
*/
public function testExceptionWithoutSyntax($resourceString)
public function testExceptionWithoutSyntax(string $resourceString): void
{
$loader = new ObjectRouteLoaderForTest();
$loader->load($resourceString);
@@ -79,8 +79,12 @@ class ObjectRouteLoaderTest extends TestCase
public function getBadResourceStrings()
{
return [
['Foo'],
['Foo:Bar:baz'],
['Foo::Bar::baz'],
['Foo:'],
['Foo::'],
[':Foo'],
['::Foo'],
];
}

View File

@@ -84,6 +84,80 @@ class PhpFileLoaderTest extends TestCase
);
}
public function testLoadingRouteWithDefaults()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.php');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.php'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('utf8.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('some_route', new Route('/'));
$expectedRoutes->add('some_utf8_route', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new PhpFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.php');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.php'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.php'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testRoutingConfigurator()
{
$locator = new FileLocator([__DIR__.'/../Fixtures']);

View File

@@ -13,7 +13,10 @@ namespace Symfony\Component\Routing\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\XmlFileLoader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader;
class XmlFileLoaderTest extends TestCase
@@ -83,24 +86,79 @@ class XmlFileLoaderTest extends TestCase
}
}
public function testUtf8Route()
public function testLoadingRouteWithDefaults()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.xml');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.xml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.xml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.xml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routeCollection = $loader->load('utf8.xml');
$routes = $routeCollection->all();
$routes = $loader->load('utf8.xml');
$this->assertCount(2, $routes, 'Two routes are loaded');
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
$this->assertCount(2, $routes);
$utf8Route = $routeCollection->get('app_utf8');
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('app_utf8', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$this->assertSame('/utf8', $utf8Route->getPath());
$this->assertTrue($utf8Route->getOption('utf8'), 'Must be utf8');
$expectedRoutes->add('app_no_utf8', $route = new Route('/no-utf8'));
$route->setOption('utf8', false);
$noUtf8Route = $routeCollection->get('app_no_utf8');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.xml'));
$this->assertSame('/no-utf8', $noUtf8Route->getPath());
$this->assertFalse($noUtf8Route->getOption('utf8'), 'Must not be utf8');
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new XmlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.xml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.xml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.xml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadLocalized()

View File

@@ -15,6 +15,8 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class YamlFileLoaderTest extends TestCase
{
@@ -222,6 +224,80 @@ class YamlFileLoaderTest extends TestCase
$loader->load('http://remote.com/here.yml');
}
public function testLoadingRouteWithDefaults()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('defaults.yml');
$this->assertCount(1, $routes);
$defaultsRoute = $routes->get('defaults');
$this->assertSame('/defaults', $defaultsRoute->getPath());
$this->assertSame('en', $defaultsRoute->getDefault('_locale'));
$this->assertSame('html', $defaultsRoute->getDefault('_format'));
}
public function testLoadingImportedRoutesWithDefaults()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures']));
$routes = $loader->load('importer-with-defaults.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('one', $localeRoute = new Route('/defaults/one'));
$localeRoute->setDefault('_locale', 'g_locale');
$localeRoute->setDefault('_format', 'g_format');
$expectedRoutes->add('two', $formatRoute = new Route('/defaults/two'));
$formatRoute->setDefault('_locale', 'g_locale');
$formatRoute->setDefault('_format', 'g_format');
$formatRoute->setDefault('specific', 'imported');
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/imported-with-defaults.yml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/importer-with-defaults.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8Route()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('utf8.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('some_route', new Route('/'));
$expectedRoutes->add('some_utf8_route', $route = new Route('/utf8'));
$route->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/utf8.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingUtf8ImportedRoutes()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));
$routes = $loader->load('importer-with-utf8.yml');
$this->assertCount(2, $routes);
$expectedRoutes = new RouteCollection();
$expectedRoutes->add('utf8_one', $one = new Route('/one'));
$one->setOption('utf8', true);
$expectedRoutes->add('utf8_two', $two = new Route('/two'));
$two->setOption('utf8', true);
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/imported-with-utf8.yml'));
$expectedRoutes->addResource(new FileResource(__DIR__.'/../Fixtures/localized/importer-with-utf8.yml'));
$this->assertEquals($expectedRoutes, $routes);
}
public function testLoadingLocalizedRoute()
{
$loader = new YamlFileLoader(new FileLocator([__DIR__.'/../Fixtures/localized']));

View File

@@ -0,0 +1,40 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Tests\Matcher;
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
class CompiledRedirectableUrlMatcherTest extends RedirectableUrlMatcherTest
{
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
{
$dumper = new CompiledUrlMatcherDumper($routes);
$compiledRoutes = $dumper->getCompiledRoutes();
return $this->getMockBuilder(TestCompiledRedirectableUrlMatcher::class)
->setConstructorArgs([$compiledRoutes, $context ?: new RequestContext()])
->setMethods(['redirect'])
->getMock();
}
}
class TestCompiledRedirectableUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface
{
public function redirect($path, $route, $scheme = null)
{
return [];
}
}

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Tests\Matcher;
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
class CompiledUrlMatcherTest extends UrlMatcherTest
{
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
{
$dumper = new CompiledUrlMatcherDumper($routes);
return new CompiledUrlMatcher($dumper->getCompiledRoutes(), $context ?: new RequestContext());
}
}

View File

@@ -17,6 +17,9 @@ use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
/**
* @group legacy
*/
class DumpedRedirectableUrlMatcherTest extends RedirectableUrlMatcherTest
{
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)

View File

@@ -15,6 +15,9 @@ use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
/**
* @group legacy
*/
class DumpedUrlMatcherTest extends UrlMatcherTest
{
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)

View File

@@ -0,0 +1,496 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
class CompiledUrlMatcherDumperTest extends TestCase
{
/**
* @var string
*/
private $dumpPath;
protected function setUp()
{
parent::setUp();
$this->dumpPath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_matcher.'.uniqid('CompiledUrlMatcher').'.php';
}
protected function tearDown()
{
parent::tearDown();
@unlink($this->dumpPath);
}
public function testRedirectPreservesUrlEncoding()
{
$collection = new RouteCollection();
$collection->add('foo', new Route('/foo:bar/'));
$matcher = $this->generateDumpedMatcher($collection);
$matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/', 'foo')->willReturn([]);
$matcher->match('/foo%3Abar');
}
/**
* @dataProvider getRouteCollections
*/
public function testDump(RouteCollection $collection, $fixture)
{
$basePath = __DIR__.'/../../Fixtures/dumper/';
$dumper = new CompiledUrlMatcherDumper($collection);
$this->assertStringEqualsFile($basePath.$fixture, $dumper->dump());
}
public function getRouteCollections()
{
/* test case 1 */
$collection = new RouteCollection();
$collection->add('overridden', new Route('/overridden'));
// defaults and requirements
$collection->add('foo', new Route(
'/foo/{bar}',
['def' => 'test'],
['bar' => 'baz|symfony']
));
// method requirement
$collection->add('bar', new Route(
'/bar/{foo}',
[],
[],
[],
'',
[],
['GET', 'head']
));
// GET method requirement automatically adds HEAD as valid
$collection->add('barhead', new Route(
'/barhead/{foo}',
[],
[],
[],
'',
[],
['GET']
));
// simple
$collection->add('baz', new Route(
'/test/baz'
));
// simple with extension
$collection->add('baz2', new Route(
'/test/baz.html'
));
// trailing slash
$collection->add('baz3', new Route(
'/test/baz3/'
));
// trailing slash with variable
$collection->add('baz4', new Route(
'/test/{foo}/'
));
// trailing slash and method
$collection->add('baz5', new Route(
'/test/{foo}/',
[],
[],
[],
'',
[],
['post']
));
// complex name
$collection->add('baz.baz6', new Route(
'/test/{foo}/',
[],
[],
[],
'',
[],
['put']
));
// defaults without variable
$collection->add('foofoo', new Route(
'/foofoo',
['def' => 'test']
));
// pattern with quotes
$collection->add('quoter', new Route(
'/{quoter}',
[],
['quoter' => '[\']+']
));
// space in pattern
$collection->add('space', new Route(
'/spa ce'
));
// prefixes
$collection1 = new RouteCollection();
$collection1->add('overridden', new Route('/overridden1'));
$collection1->add('foo1', (new Route('/{foo}'))->setMethods('PUT'));
$collection1->add('bar1', new Route('/{bar}'));
$collection1->addPrefix('/b\'b');
$collection2 = new RouteCollection();
$collection2->addCollection($collection1);
$collection2->add('overridden', new Route('/{var}', [], ['var' => '.*']));
$collection1 = new RouteCollection();
$collection1->add('foo2', new Route('/{foo1}'));
$collection1->add('bar2', new Route('/{bar1}'));
$collection1->addPrefix('/b\'b');
$collection2->addCollection($collection1);
$collection2->addPrefix('/a');
$collection->addCollection($collection2);
// overridden through addCollection() and multiple sub-collections with no own prefix
$collection1 = new RouteCollection();
$collection1->add('overridden2', new Route('/old'));
$collection1->add('helloWorld', new Route('/hello/{who}', ['who' => 'World!']));
$collection2 = new RouteCollection();
$collection3 = new RouteCollection();
$collection3->add('overridden2', new Route('/new'));
$collection3->add('hey', new Route('/hey/'));
$collection2->addCollection($collection3);
$collection1->addCollection($collection2);
$collection1->addPrefix('/multi');
$collection->addCollection($collection1);
// "dynamic" prefix
$collection1 = new RouteCollection();
$collection1->add('foo3', new Route('/{foo}'));
$collection1->add('bar3', new Route('/{bar}'));
$collection1->addPrefix('/b');
$collection1->addPrefix('{_locale}');
$collection->addCollection($collection1);
// route between collections
$collection->add('ababa', new Route('/ababa'));
// collection with static prefix but only one route
$collection1 = new RouteCollection();
$collection1->add('foo4', new Route('/{foo}'));
$collection1->addPrefix('/aba');
$collection->addCollection($collection1);
// prefix and host
$collection1 = new RouteCollection();
$route1 = new Route('/route1', [], [], [], 'a.example.com');
$collection1->add('route1', $route1);
$route2 = new Route('/c2/route2', [], [], [], 'a.example.com');
$collection1->add('route2', $route2);
$route3 = new Route('/c2/route3', [], [], [], 'b.example.com');
$collection1->add('route3', $route3);
$route4 = new Route('/route4', [], [], [], 'a.example.com');
$collection1->add('route4', $route4);
$route5 = new Route('/route5', [], [], [], 'c.example.com');
$collection1->add('route5', $route5);
$route6 = new Route('/route6', [], [], [], null);
$collection1->add('route6', $route6);
$collection->addCollection($collection1);
// host and variables
$collection1 = new RouteCollection();
$route11 = new Route('/route11', [], [], [], '{var1}.example.com');
$collection1->add('route11', $route11);
$route12 = new Route('/route12', ['var1' => 'val'], [], [], '{var1}.example.com');
$collection1->add('route12', $route12);
$route13 = new Route('/route13/{name}', [], [], [], '{var1}.example.com');
$collection1->add('route13', $route13);
$route14 = new Route('/route14/{name}', ['var1' => 'val'], [], [], '{var1}.example.com');
$collection1->add('route14', $route14);
$route15 = new Route('/route15/{name}', [], [], [], 'c.example.com');
$collection1->add('route15', $route15);
$route16 = new Route('/route16/{name}', ['var1' => 'val'], [], [], null);
$collection1->add('route16', $route16);
$route17 = new Route('/route17', [], [], [], null);
$collection1->add('route17', $route17);
$collection->addCollection($collection1);
// multiple sub-collections with a single route and a prefix each
$collection1 = new RouteCollection();
$collection1->add('a', new Route('/a...'));
$collection2 = new RouteCollection();
$collection2->add('b', new Route('/{var}'));
$collection3 = new RouteCollection();
$collection3->add('c', new Route('/{var}'));
$collection3->addPrefix('/c');
$collection2->addCollection($collection3);
$collection2->addPrefix('/b');
$collection1->addCollection($collection2);
$collection1->addPrefix('/a');
$collection->addCollection($collection1);
/* test case 2 */
$redirectCollection = clone $collection;
// force HTTPS redirection
$redirectCollection->add('secure', new Route(
'/secure',
[],
[],
[],
'',
['https']
));
// force HTTP redirection
$redirectCollection->add('nonsecure', new Route(
'/nonsecure',
[],
[],
[],
'',
['http']
));
/* test case 3 */
$rootprefixCollection = new RouteCollection();
$rootprefixCollection->add('static', new Route('/test'));
$rootprefixCollection->add('dynamic', new Route('/{var}'));
$rootprefixCollection->addPrefix('rootprefix');
$route = new Route('/with-condition');
$route->setCondition('context.getMethod() == "GET"');
$rootprefixCollection->add('with-condition', $route);
/* test case 4 */
$headMatchCasesCollection = new RouteCollection();
$headMatchCasesCollection->add('just_head', new Route(
'/just_head',
[],
[],
[],
'',
[],
['HEAD']
));
$headMatchCasesCollection->add('head_and_get', new Route(
'/head_and_get',
[],
[],
[],
'',
[],
['HEAD', 'GET']
));
$headMatchCasesCollection->add('get_and_head', new Route(
'/get_and_head',
[],
[],
[],
'',
[],
['GET', 'HEAD']
));
$headMatchCasesCollection->add('post_and_head', new Route(
'/post_and_head',
[],
[],
[],
'',
[],
['POST', 'HEAD']
));
$headMatchCasesCollection->add('put_and_post', new Route(
'/put_and_post',
[],
[],
[],
'',
[],
['PUT', 'POST']
));
$headMatchCasesCollection->add('put_and_get_and_head', new Route(
'/put_and_post',
[],
[],
[],
'',
[],
['PUT', 'GET', 'HEAD']
));
/* test case 5 */
$groupOptimisedCollection = new RouteCollection();
$groupOptimisedCollection->add('a_first', new Route('/a/11'));
$groupOptimisedCollection->add('a_second', new Route('/a/22'));
$groupOptimisedCollection->add('a_third', new Route('/a/333'));
$groupOptimisedCollection->add('a_wildcard', new Route('/{param}'));
$groupOptimisedCollection->add('a_fourth', new Route('/a/44/'));
$groupOptimisedCollection->add('a_fifth', new Route('/a/55/'));
$groupOptimisedCollection->add('a_sixth', new Route('/a/66/'));
$groupOptimisedCollection->add('nested_wildcard', new Route('/nested/{param}'));
$groupOptimisedCollection->add('nested_a', new Route('/nested/group/a/'));
$groupOptimisedCollection->add('nested_b', new Route('/nested/group/b/'));
$groupOptimisedCollection->add('nested_c', new Route('/nested/group/c/'));
$groupOptimisedCollection->add('slashed_a', new Route('/slashed/group/'));
$groupOptimisedCollection->add('slashed_b', new Route('/slashed/group/b/'));
$groupOptimisedCollection->add('slashed_c', new Route('/slashed/group/c/'));
/* test case 6 & 7 */
$trailingSlashCollection = new RouteCollection();
$trailingSlashCollection->add('simple_trailing_slash_no_methods', new Route('/trailing/simple/no-methods/', [], [], [], '', [], []));
$trailingSlashCollection->add('simple_trailing_slash_GET_method', new Route('/trailing/simple/get-method/', [], [], [], '', [], ['GET']));
$trailingSlashCollection->add('simple_trailing_slash_HEAD_method', new Route('/trailing/simple/head-method/', [], [], [], '', [], ['HEAD']));
$trailingSlashCollection->add('simple_trailing_slash_POST_method', new Route('/trailing/simple/post-method/', [], [], [], '', [], ['POST']));
$trailingSlashCollection->add('regex_trailing_slash_no_methods', new Route('/trailing/regex/no-methods/{param}/', [], [], [], '', [], []));
$trailingSlashCollection->add('regex_trailing_slash_GET_method', new Route('/trailing/regex/get-method/{param}/', [], [], [], '', [], ['GET']));
$trailingSlashCollection->add('regex_trailing_slash_HEAD_method', new Route('/trailing/regex/head-method/{param}/', [], [], [], '', [], ['HEAD']));
$trailingSlashCollection->add('regex_trailing_slash_POST_method', new Route('/trailing/regex/post-method/{param}/', [], [], [], '', [], ['POST']));
$trailingSlashCollection->add('simple_not_trailing_slash_no_methods', new Route('/not-trailing/simple/no-methods', [], [], [], '', [], []));
$trailingSlashCollection->add('simple_not_trailing_slash_GET_method', new Route('/not-trailing/simple/get-method', [], [], [], '', [], ['GET']));
$trailingSlashCollection->add('simple_not_trailing_slash_HEAD_method', new Route('/not-trailing/simple/head-method', [], [], [], '', [], ['HEAD']));
$trailingSlashCollection->add('simple_not_trailing_slash_POST_method', new Route('/not-trailing/simple/post-method', [], [], [], '', [], ['POST']));
$trailingSlashCollection->add('regex_not_trailing_slash_no_methods', new Route('/not-trailing/regex/no-methods/{param}', [], [], [], '', [], []));
$trailingSlashCollection->add('regex_not_trailing_slash_GET_method', new Route('/not-trailing/regex/get-method/{param}', [], [], [], '', [], ['GET']));
$trailingSlashCollection->add('regex_not_trailing_slash_HEAD_method', new Route('/not-trailing/regex/head-method/{param}', [], [], [], '', [], ['HEAD']));
$trailingSlashCollection->add('regex_not_trailing_slash_POST_method', new Route('/not-trailing/regex/post-method/{param}', [], [], [], '', [], ['POST']));
/* test case 8 */
$unicodeCollection = new RouteCollection();
$unicodeCollection->add('a', new Route('/{a}', [], ['a' => 'a'], ['utf8' => false]));
$unicodeCollection->add('b', new Route('/{a}', [], ['a' => '.'], ['utf8' => true]));
$unicodeCollection->add('c', new Route('/{a}', [], ['a' => '.'], ['utf8' => false]));
/* test case 9 */
$hostTreeCollection = new RouteCollection();
$hostTreeCollection->add('a', (new Route('/'))->setHost('{d}.e.c.b.a'));
$hostTreeCollection->add('b', (new Route('/'))->setHost('d.c.b.a'));
$hostTreeCollection->add('c', (new Route('/'))->setHost('{e}.e.c.b.a'));
/* test case 10 */
$chunkedCollection = new RouteCollection();
for ($i = 0; $i < 1000; ++$i) {
$h = substr(md5($i), 0, 6);
$chunkedCollection->add('_'.$i, new Route('/'.$h.'/{a}/{b}/{c}/'.$h));
}
/* test case 11 */
$demoCollection = new RouteCollection();
$demoCollection->add('a', new Route('/admin/post/'));
$demoCollection->add('b', new Route('/admin/post/new'));
$demoCollection->add('c', (new Route('/admin/post/{id}'))->setRequirements(['id' => '\d+']));
$demoCollection->add('d', (new Route('/admin/post/{id}/edit'))->setRequirements(['id' => '\d+']));
$demoCollection->add('e', (new Route('/admin/post/{id}/delete'))->setRequirements(['id' => '\d+']));
$demoCollection->add('f', new Route('/blog/'));
$demoCollection->add('g', new Route('/blog/rss.xml'));
$demoCollection->add('h', (new Route('/blog/page/{page}'))->setRequirements(['id' => '\d+']));
$demoCollection->add('i', (new Route('/blog/posts/{page}'))->setRequirements(['id' => '\d+']));
$demoCollection->add('j', (new Route('/blog/comments/{id}/new'))->setRequirements(['id' => '\d+']));
$demoCollection->add('k', new Route('/blog/search'));
$demoCollection->add('l', new Route('/login'));
$demoCollection->add('m', new Route('/logout'));
$demoCollection->addPrefix('/{_locale}');
$demoCollection->add('n', new Route('/{_locale}'));
$demoCollection->addRequirements(['_locale' => 'en|fr']);
$demoCollection->addDefaults(['_locale' => 'en']);
/* test case 12 */
$suffixCollection = new RouteCollection();
$suffixCollection->add('r1', new Route('abc{foo}/1'));
$suffixCollection->add('r2', new Route('abc{foo}/2'));
$suffixCollection->add('r10', new Route('abc{foo}/10'));
$suffixCollection->add('r20', new Route('abc{foo}/20'));
$suffixCollection->add('r100', new Route('abc{foo}/100'));
$suffixCollection->add('r200', new Route('abc{foo}/200'));
/* test case 13 */
$hostCollection = new RouteCollection();
$hostCollection->add('r1', (new Route('abc{foo}'))->setHost('{foo}.exampple.com'));
$hostCollection->add('r2', (new Route('abc{foo}'))->setHost('{foo}.exampple.com'));
return [
[new RouteCollection(), 'compiled_url_matcher0.php'],
[$collection, 'compiled_url_matcher1.php'],
[$redirectCollection, 'compiled_url_matcher2.php'],
[$rootprefixCollection, 'compiled_url_matcher3.php'],
[$headMatchCasesCollection, 'compiled_url_matcher4.php'],
[$groupOptimisedCollection, 'compiled_url_matcher5.php'],
[$trailingSlashCollection, 'compiled_url_matcher6.php'],
[$trailingSlashCollection, 'compiled_url_matcher7.php'],
[$unicodeCollection, 'compiled_url_matcher8.php'],
[$hostTreeCollection, 'compiled_url_matcher9.php'],
[$chunkedCollection, 'compiled_url_matcher10.php'],
[$demoCollection, 'compiled_url_matcher11.php'],
[$suffixCollection, 'compiled_url_matcher12.php'],
[$hostCollection, 'compiled_url_matcher13.php'],
];
}
private function generateDumpedMatcher(RouteCollection $collection)
{
$dumper = new CompiledUrlMatcherDumper($collection);
$code = $dumper->dump();
file_put_contents($this->dumpPath, $code);
$compiledRoutes = require $this->dumpPath;
return $this->getMockBuilder(TestCompiledUrlMatcher::class)
->setConstructorArgs([$compiledRoutes, new RequestContext()])
->setMethods(['redirect'])
->getMock();
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Symfony\Component\Routing\Route cannot contain objects
*/
public function testGenerateDumperMatcherWithObject()
{
$routeCollection = new RouteCollection();
$routeCollection->add('_', new Route('/', [new \stdClass()]));
$dumper = new CompiledUrlMatcherDumper($routeCollection);
$dumper->dump();
}
}
class TestCompiledUrlMatcher extends CompiledUrlMatcher implements RedirectableUrlMatcherInterface
{
public function redirect($path, $route, $scheme = null)
{
return [];
}
}

View File

@@ -19,6 +19,9 @@ use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* @group legacy
*/
class PhpMatcherDumperTest extends TestCase
{
/**

View File

@@ -187,6 +187,26 @@ class UrlMatcherTest extends TestCase
$this->assertEquals(['_route' => '$péß^a|'], $matcher->match('/bar'));
}
public function testMatchImportantVariable()
{
$collection = new RouteCollection();
$collection->add('index', new Route('/index.{!_format}', ['_format' => 'xml']));
$matcher = $this->getUrlMatcher($collection);
$this->assertEquals(['_route' => 'index', '_format' => 'xml'], $matcher->match('/index.xml'));
}
/**
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
public function testShortPathDoesNotMatchImportantVariable()
{
$collection = new RouteCollection();
$collection->add('index', new Route('/index.{!_format}', ['_format' => 'xml']));
$this->getUrlMatcher($collection)->match('/index');
}
/**
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
*/
@@ -232,7 +252,7 @@ class UrlMatcherTest extends TestCase
$matcher = $this->getUrlMatcher($collection);
$this->assertEquals(['_route' => 'foo'], $matcher->match('/foo1'));
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$this->assertEquals([], $matcher->match('/foo'));
}
@@ -301,7 +321,7 @@ class UrlMatcherTest extends TestCase
// z and _format are optional.
$this->assertEquals(['w' => 'wwwww', 'x' => 'x', 'y' => 'y', 'z' => 'default-z', '_format' => 'html', '_route' => 'test'], $matcher->match('/wwwwwxy'));
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$matcher->match('/wxy.html');
}
@@ -316,7 +336,7 @@ class UrlMatcherTest extends TestCase
// Usually the character in front of an optional parameter can be left out, e.g. with pattern '/get/{what}' just '/get' would match.
// But here the 't' in 'get' is not a separating character, so it makes no sense to match without it.
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$this->expectException('Symfony\Component\Routing\Exception\ResourceNotFoundException');
$matcher->match('/ge');
}
@@ -727,6 +747,7 @@ class UrlMatcherTest extends TestCase
/**
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
* @expectedExceptionMessage No routes found for "/".
*/
public function testSchemeAndMethodMismatch()
{

View File

@@ -93,12 +93,9 @@ class RouterTest extends TestCase
$this->assertSame($routeCollection, $this->router->getRouteCollection());
}
/**
* @dataProvider provideMatcherOptionsPreventingCaching
*/
public function testMatcherIsCreatedIfCacheIsNotConfigured($option)
public function testMatcherIsCreatedIfCacheIsNotConfigured()
{
$this->router->setOption($option, null);
$this->router->setOption('cache_dir', null);
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
@@ -107,20 +104,9 @@ class RouterTest extends TestCase
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
}
public function provideMatcherOptionsPreventingCaching()
public function testGeneratorIsCreatedIfCacheIsNotConfigured()
{
return [
['cache_dir'],
['matcher_cache_class'],
];
}
/**
* @dataProvider provideGeneratorOptionsPreventingCaching
*/
public function testGeneratorIsCreatedIfCacheIsNotConfigured($option)
{
$this->router->setOption($option, null);
$this->router->setOption('cache_dir', null);
$this->loader->expects($this->once())
->method('load')->with('routing.yml', null)
@@ -129,14 +115,6 @@ class RouterTest extends TestCase
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator());
}
public function provideGeneratorOptionsPreventingCaching()
{
return [
['cache_dir'],
['generator_cache_class'],
];
}
public function testMatchRequestWithUrlMatcherInterface()
{
$matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock();