update2
This commit is contained in:
parent
98419bd18d
commit
8a69e45efa
4919 changed files with 28311 additions and 224136 deletions
0
pfosten/vendor/symfony/routing/Tests/Annotation/RouteTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Annotation/RouteTest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/CompiledRouteTest.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/CompiledRouteTest.php
vendored
Executable file → Normal file
|
|
@ -18,7 +18,7 @@ class CompiledRouteTest extends TestCase
|
|||
{
|
||||
public function testAccessors()
|
||||
{
|
||||
$compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), array(), array(), array(), array('variables'));
|
||||
$compiled = new CompiledRoute('prefix', 'regex', array('tokens'), array(), null, array(), array(), array('variables'));
|
||||
$this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument');
|
||||
$this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument');
|
||||
$this->assertEquals(array('tokens'), $compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument');
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
|
||||
/**
|
||||
* XmlFileLoader with schema validation turned off.
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Fixtures/annotated.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/annotated.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/bad_format.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/bad_format.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/bar.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/bar.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml
vendored
Executable file → Normal file
|
|
@ -1,163 +0,0 @@
|
|||
# skip "real" requests
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule .* - [QSA,L]
|
||||
|
||||
# foo
|
||||
RewriteCond %{REQUEST_URI} ^/foo/(baz|symfony)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foo,E=_ROUTING_param_bar:%1,E=_ROUTING_default_def:test]
|
||||
|
||||
# foobar
|
||||
RewriteCond %{REQUEST_URI} ^/foo(?:/([^/]++))?$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:foobar,E=_ROUTING_param_bar:%1,E=_ROUTING_default_bar:toto]
|
||||
|
||||
# bar
|
||||
RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/bar/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:bar,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baragain
|
||||
RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_POST:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/baragain/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baragain,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz]
|
||||
|
||||
# baz2
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz\.html$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz2]
|
||||
|
||||
# baz3
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz3$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz3/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz3]
|
||||
|
||||
# baz4
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz4,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz5
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [NC]
|
||||
RewriteRule .* - [S=2,E=_ROUTING_allow_GET:1,E=_ROUTING_allow_HEAD:1]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)$
|
||||
RewriteRule .* $0/ [QSA,L,R=301]
|
||||
RewriteCond %{REQUEST_URI} ^/test/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz5unsafe
|
||||
RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$
|
||||
RewriteCond %{REQUEST_METHOD} !^(POST)$ [NC]
|
||||
RewriteRule .* - [S=1,E=_ROUTING_allow_POST:1]
|
||||
RewriteCond %{REQUEST_URI} ^/testunsafe/([^/]++)/$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz5unsafe,E=_ROUTING_param_foo:%1]
|
||||
|
||||
# baz6
|
||||
RewriteCond %{REQUEST_URI} ^/test/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz6,E=_ROUTING_default_foo:bar\ baz]
|
||||
|
||||
# baz7
|
||||
RewriteCond %{REQUEST_URI} ^/te\ st/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz7]
|
||||
|
||||
# baz8
|
||||
RewriteCond %{REQUEST_URI} ^/te\\\ st/baz$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz8]
|
||||
|
||||
# baz9
|
||||
RewriteCond %{REQUEST_URI} ^/test/(te\\\ st)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:baz9,E=_ROUTING_param_baz:%1]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^a\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_1:1]
|
||||
|
||||
# route1
|
||||
RewriteCond %{ENV:__ROUTING_host_1} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route1$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route1]
|
||||
|
||||
# route2
|
||||
RewriteCond %{ENV:__ROUTING_host_1} =1
|
||||
RewriteCond %{REQUEST_URI} ^/c2/route2$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route2]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^b\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_2:1]
|
||||
|
||||
# route3
|
||||
RewriteCond %{ENV:__ROUTING_host_2} =1
|
||||
RewriteCond %{REQUEST_URI} ^/c2/route3$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route3]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^a\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_3:1]
|
||||
|
||||
# route4
|
||||
RewriteCond %{ENV:__ROUTING_host_3} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route4$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route4]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^c\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_4:1]
|
||||
|
||||
# route5
|
||||
RewriteCond %{ENV:__ROUTING_host_4} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route5$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route5]
|
||||
|
||||
# route6
|
||||
RewriteCond %{REQUEST_URI} ^/route6$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route6]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^([^\.]++)\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_5:1,E=__ROUTING_host_5_var1:%1]
|
||||
|
||||
# route11
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route11$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route11,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1}]
|
||||
|
||||
# route12
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route12$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route12,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_default_var1:val]
|
||||
|
||||
# route13
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route13/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route13,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1]
|
||||
|
||||
# route14
|
||||
RewriteCond %{ENV:__ROUTING_host_5} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route14/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route14,E=_ROUTING_param_var1:%{ENV:__ROUTING_host_5_var1},E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
|
||||
|
||||
RewriteCond %{HTTP:Host} ^c\.example\.com$
|
||||
RewriteRule .? - [E=__ROUTING_host_6:1]
|
||||
|
||||
# route15
|
||||
RewriteCond %{ENV:__ROUTING_host_6} =1
|
||||
RewriteCond %{REQUEST_URI} ^/route15/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route15,E=_ROUTING_param_name:%1]
|
||||
|
||||
# route16
|
||||
RewriteCond %{REQUEST_URI} ^/route16/([^/]++)$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route16,E=_ROUTING_param_name:%1,E=_ROUTING_default_var1:val]
|
||||
|
||||
# route17
|
||||
RewriteCond %{REQUEST_URI} ^/route17$
|
||||
RewriteRule .* app.php [QSA,L,E=_ROUTING_route:route17]
|
||||
|
||||
# 405 Method Not Allowed
|
||||
RewriteCond %{ENV:_ROUTING__allow_GET} =1 [OR]
|
||||
RewriteCond %{ENV:_ROUTING__allow_HEAD} =1 [OR]
|
||||
RewriteCond %{ENV:_ROUTING__allow_POST} =1
|
||||
RewriteRule .* app.php [QSA,L]
|
||||
101
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php
vendored
Executable file → Normal file
101
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php
vendored
Executable file → Normal file
|
|
@ -5,39 +5,32 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/foo')) {
|
||||
// foo
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
}
|
||||
|
||||
|
|
@ -50,24 +43,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
goto not_bar;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_barhead;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
|
|
@ -93,36 +88,38 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
}
|
||||
|
||||
// baz4
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
}
|
||||
|
||||
// baz5
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_baz5;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('PUT' !== $canonicalMethod) {
|
||||
$allow[] = 'PUT';
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
if (!in_array($requestMethod, array('PUT'))) {
|
||||
$allow = array_merge($allow, array('PUT'));
|
||||
goto not_bazbaz6;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -134,30 +131,30 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
if (0 === strpos($pathinfo, '/a')) {
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo1
|
||||
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
|
||||
}
|
||||
|
||||
// bar1
|
||||
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overridden
|
||||
if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo2
|
||||
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
|
||||
}
|
||||
|
||||
// bar2
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +164,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
|
||||
}
|
||||
|
||||
|
|
@ -184,12 +181,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
}
|
||||
|
||||
// foo3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
|
||||
}
|
||||
|
||||
// bar3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +197,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +205,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
|
|
@ -221,7 +218,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
|
|
@ -229,7 +226,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
|
|
@ -237,7 +234,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
|
|
@ -250,7 +247,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ('/route11' === $pathinfo) {
|
||||
|
|
@ -263,12 +260,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
}
|
||||
|
||||
// route13
|
||||
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
|
||||
}
|
||||
|
||||
// route14
|
||||
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
|
|
@ -276,16 +273,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route16
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
|
|
@ -301,17 +298,21 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
|
||||
}
|
||||
|
||||
// c
|
||||
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
# skip "real" requests
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule .* - [QSA,L]
|
||||
|
||||
# foo
|
||||
RewriteCond %{REQUEST_URI} ^/foo$
|
||||
RewriteRule .* ap\ p_d\ ev.php [QSA,L,E=_ROUTING_route:foo]
|
||||
161
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php
vendored
Executable file → Normal file
161
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php
vendored
Executable file → Normal file
|
|
@ -5,39 +5,32 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/foo')) {
|
||||
// foo
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
}
|
||||
|
||||
|
|
@ -50,24 +43,26 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (preg_match('#^/bar/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
goto not_bar;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/barhead') && preg_match('#^/barhead/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_barhead;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'barhead')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
|
|
@ -87,50 +82,64 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
// baz3
|
||||
if ('/test/baz3' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'baz3');
|
||||
$ret = array('_route' => 'baz3');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_baz3;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz3'));
|
||||
}
|
||||
|
||||
return array('_route' => 'baz3');
|
||||
return $ret;
|
||||
}
|
||||
not_baz3:
|
||||
|
||||
}
|
||||
|
||||
// baz4
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/?$#s', $pathinfo, $matches)) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'baz4');
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_baz4;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'baz4'));
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz4')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz4:
|
||||
|
||||
// baz5
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_baz5;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz5')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('PUT' !== $canonicalMethod) {
|
||||
$allow[] = 'PUT';
|
||||
if (preg_match('#^/test/(?P<foo>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
if (!in_array($requestMethod, array('PUT'))) {
|
||||
$allow = array_merge($allow, array('PUT'));
|
||||
goto not_bazbaz6;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'baz.baz6')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -142,30 +151,30 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
if (0 === strpos($pathinfo, '/a')) {
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo1
|
||||
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo1')), array ());
|
||||
}
|
||||
|
||||
// bar1
|
||||
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overridden
|
||||
if (preg_match('#^/a/(?P<var>.*)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/(?P<var>.*)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'overridden')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo2
|
||||
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<foo1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
|
||||
}
|
||||
|
||||
// bar2
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -175,18 +184,24 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/multi/hello') && preg_match('#^/multi/hello(?:/(?P<who>[^/]++))?$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'helloWorld')), array ( 'who' => 'World!',));
|
||||
}
|
||||
|
||||
// hey
|
||||
if ('/multi/hey' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'hey');
|
||||
$ret = array('_route' => 'hey');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_hey;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'hey'));
|
||||
}
|
||||
|
||||
return array('_route' => 'hey');
|
||||
return $ret;
|
||||
}
|
||||
not_hey:
|
||||
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
|
|
@ -196,12 +211,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
}
|
||||
|
||||
// foo3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo3')), array ());
|
||||
}
|
||||
|
||||
// bar3
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<_locale>[^/]++)/b/(?P<bar>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +227,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +235,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
|
|
@ -233,7 +248,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
|
|
@ -241,7 +256,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
|
|
@ -249,7 +264,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
|
|
@ -262,7 +277,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ('/route11' === $pathinfo) {
|
||||
|
|
@ -275,12 +290,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
}
|
||||
|
||||
// route13
|
||||
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route13') && preg_match('#^/route13/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route13')), array ());
|
||||
}
|
||||
|
||||
// route14
|
||||
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route14') && preg_match('#^/route14/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
|
|
@ -288,16 +303,16 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#si', $host, $hostMatches)) {
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route15') && preg_match('#^/route15/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route15')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route16
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/route16') && preg_match('#^/route16/(?P<name>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
|
|
@ -313,12 +328,12 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/a/b/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'b')), array ());
|
||||
}
|
||||
|
||||
// c
|
||||
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/a/b/c') && preg_match('#^/a/b/c/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -326,22 +341,38 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
// secure
|
||||
if ('/secure' === $pathinfo) {
|
||||
$ret = array('_route' => 'secure');
|
||||
$requiredSchemes = array ( 'https' => 0,);
|
||||
if (!isset($requiredSchemes[$scheme])) {
|
||||
return $this->redirect($pathinfo, 'secure', key($requiredSchemes));
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_secure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return array('_route' => 'secure');
|
||||
return $ret;
|
||||
}
|
||||
not_secure:
|
||||
|
||||
// nonsecure
|
||||
if ('/nonsecure' === $pathinfo) {
|
||||
$ret = array('_route' => 'nonsecure');
|
||||
$requiredSchemes = array ( 'http' => 0,);
|
||||
if (!isset($requiredSchemes[$scheme])) {
|
||||
return $this->redirect($pathinfo, 'nonsecure', key($requiredSchemes));
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_nonsecure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return array('_route' => 'nonsecure');
|
||||
return $ret;
|
||||
}
|
||||
not_nonsecure:
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
|
|
|
|||
19
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php
vendored
Executable file → Normal file
19
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php
vendored
Executable file → Normal file
|
|
@ -5,36 +5,29 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/rootprefix')) {
|
||||
// static
|
||||
if ('/rootprefix/test' === $pathinfo) {
|
||||
|
|
@ -42,7 +35,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
}
|
||||
|
||||
// dynamic
|
||||
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +46,10 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
return array('_route' => 'with-condition');
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
58
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Executable file → Normal file
58
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Executable file → Normal file
|
|
@ -5,94 +5,108 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
// just_head
|
||||
if ('/just_head' === $pathinfo) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
$ret = array('_route' => 'just_head');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_just_head;
|
||||
}
|
||||
|
||||
return array('_route' => 'just_head');
|
||||
return $ret;
|
||||
}
|
||||
not_just_head:
|
||||
|
||||
// head_and_get
|
||||
if ('/head_and_get' === $pathinfo) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
$ret = array('_route' => 'head_and_get');
|
||||
if (!in_array($canonicalMethod, array('HEAD', 'GET'))) {
|
||||
$allow = array_merge($allow, array('HEAD', 'GET'));
|
||||
goto not_head_and_get;
|
||||
}
|
||||
|
||||
return array('_route' => 'head_and_get');
|
||||
return $ret;
|
||||
}
|
||||
not_head_and_get:
|
||||
|
||||
// get_and_head
|
||||
if ('/get_and_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'get_and_head');
|
||||
if (!in_array($canonicalMethod, array('GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('GET', 'HEAD'));
|
||||
goto not_get_and_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_get_and_head:
|
||||
|
||||
// post_and_head
|
||||
if ('/post_and_get' === $pathinfo) {
|
||||
if ('/post_and_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'post_and_head');
|
||||
if (!in_array($requestMethod, array('POST', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('POST', 'HEAD'));
|
||||
goto not_post_and_head;
|
||||
}
|
||||
|
||||
return array('_route' => 'post_and_head');
|
||||
return $ret;
|
||||
}
|
||||
not_post_and_head:
|
||||
|
||||
if (0 === strpos($pathinfo, '/put_and_post')) {
|
||||
// put_and_post
|
||||
if ('/put_and_post' === $pathinfo) {
|
||||
$ret = array('_route' => 'put_and_post');
|
||||
if (!in_array($requestMethod, array('PUT', 'POST'))) {
|
||||
$allow = array_merge($allow, array('PUT', 'POST'));
|
||||
goto not_put_and_post;
|
||||
}
|
||||
|
||||
return array('_route' => 'put_and_post');
|
||||
return $ret;
|
||||
}
|
||||
not_put_and_post:
|
||||
|
||||
// put_and_get_and_head
|
||||
if ('/put_and_post' === $pathinfo) {
|
||||
if (!in_array($canonicalMethod, array('PUT', 'GET'))) {
|
||||
$allow = array_merge($allow, array('PUT', 'GET'));
|
||||
$ret = array('_route' => 'put_and_get_and_head');
|
||||
if (!in_array($canonicalMethod, array('PUT', 'GET', 'HEAD'))) {
|
||||
$allow = array_merge($allow, array('PUT', 'GET', 'HEAD'));
|
||||
goto not_put_and_get_and_head;
|
||||
}
|
||||
|
||||
return array('_route' => 'put_and_get_and_head');
|
||||
return $ret;
|
||||
}
|
||||
not_put_and_get_and_head:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
129
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Executable file → Normal file
129
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Executable file → Normal file
|
|
@ -5,36 +5,29 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a_first
|
||||
if ('/a/11' === $pathinfo) {
|
||||
|
|
@ -54,105 +47,163 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
}
|
||||
|
||||
// a_wildcard
|
||||
if (preg_match('#^/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (preg_match('#^/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'a_wildcard')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a_fourth
|
||||
if ('/a/44' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'a_fourth');
|
||||
$ret = array('_route' => 'a_fourth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_fourth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fourth'));
|
||||
}
|
||||
|
||||
return array('_route' => 'a_fourth');
|
||||
return $ret;
|
||||
}
|
||||
not_a_fourth:
|
||||
|
||||
// a_fifth
|
||||
if ('/a/55' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'a_fifth');
|
||||
$ret = array('_route' => 'a_fifth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_fifth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_fifth'));
|
||||
}
|
||||
|
||||
return array('_route' => 'a_fifth');
|
||||
return $ret;
|
||||
}
|
||||
not_a_fifth:
|
||||
|
||||
// a_sixth
|
||||
if ('/a/66' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'a_sixth');
|
||||
$ret = array('_route' => 'a_sixth');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_a_sixth;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'a_sixth'));
|
||||
}
|
||||
|
||||
return array('_route' => 'a_sixth');
|
||||
return $ret;
|
||||
}
|
||||
not_a_sixth:
|
||||
|
||||
}
|
||||
|
||||
// nested_wildcard
|
||||
if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/nested') && preg_match('#^/nested/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'nested_wildcard')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/nested/group')) {
|
||||
// nested_a
|
||||
if ('/nested/group/a' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'nested_a');
|
||||
$ret = array('_route' => 'nested_a');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_a;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_a'));
|
||||
}
|
||||
|
||||
return array('_route' => 'nested_a');
|
||||
return $ret;
|
||||
}
|
||||
not_nested_a:
|
||||
|
||||
// nested_b
|
||||
if ('/nested/group/b' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'nested_b');
|
||||
$ret = array('_route' => 'nested_b');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_b;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_b'));
|
||||
}
|
||||
|
||||
return array('_route' => 'nested_b');
|
||||
return $ret;
|
||||
}
|
||||
not_nested_b:
|
||||
|
||||
// nested_c
|
||||
if ('/nested/group/c' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'nested_c');
|
||||
$ret = array('_route' => 'nested_c');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_nested_c;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'nested_c'));
|
||||
}
|
||||
|
||||
return array('_route' => 'nested_c');
|
||||
return $ret;
|
||||
}
|
||||
not_nested_c:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/slashed/group')) {
|
||||
// slashed_a
|
||||
if ('/slashed/group' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'slashed_a');
|
||||
$ret = array('_route' => 'slashed_a');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_a;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_a'));
|
||||
}
|
||||
|
||||
return array('_route' => 'slashed_a');
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_a:
|
||||
|
||||
// slashed_b
|
||||
if ('/slashed/group/b' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'slashed_b');
|
||||
$ret = array('_route' => 'slashed_b');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_b;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_b'));
|
||||
}
|
||||
|
||||
return array('_route' => 'slashed_b');
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_b:
|
||||
|
||||
// slashed_c
|
||||
if ('/slashed/group/c' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'slashed_c');
|
||||
$ret = array('_route' => 'slashed_c');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_slashed_c;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'slashed_c'));
|
||||
}
|
||||
|
||||
return array('_route' => 'slashed_c');
|
||||
return $ret;
|
||||
}
|
||||
not_slashed_c:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
117
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Executable file → Normal file
117
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Executable file → Normal file
|
|
@ -5,36 +5,29 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods/' === $pathinfo) {
|
||||
|
|
@ -43,34 +36,37 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method/' === $pathinfo) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
$ret = array('_route' => 'simple_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_GET_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
if ('/trailing/simple/head-method/' === $pathinfo) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
$ret = array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
$ret = array('_route' => 'simple_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_POST_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -78,40 +74,43 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/trailing/regex')) {
|
||||
// regex_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_GET_method:
|
||||
|
||||
// regex_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -125,34 +124,37 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -160,45 +162,52 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
|
||||
// regex_not_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_not_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_GET_method:
|
||||
|
||||
// regex_not_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_not_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
175
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Executable file → Normal file
175
pfosten/vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Executable file → Normal file
|
|
@ -5,84 +5,86 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* ProjectUrlMatcher.
|
||||
*
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($pathinfo)
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($pathinfo);
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
$scheme = $context->getScheme();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_no_methods');
|
||||
$ret = array('_route' => 'simple_trailing_slash_no_methods');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_no_methods'));
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_no_methods');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_no_methods:
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method' === $trimmedPathinfo) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
$ret = array('_route' => 'simple_trailing_slash_GET_method');
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'simple_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_GET_method');
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_GET_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
if ('/trailing/simple/head-method' === $trimmedPathinfo) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
if ('/trailing/simple/head-method/' === $pathinfo) {
|
||||
$ret = array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'simple_trailing_slash_HEAD_method');
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_HEAD_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
$ret = array('_route' => 'simple_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_trailing_slash_POST_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -90,52 +92,61 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/trailing/regex')) {
|
||||
// regex_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_no_methods');
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/no-methods') && preg_match('#^/trailing/regex/no\\-methods/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_no_methods;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_no_methods'));
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_no_methods')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_no_methods:
|
||||
|
||||
// regex_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/get-method') && preg_match('#^/trailing/regex/get\\-method/(?P<param>[^/]++)/?$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
if ('/' === substr($pathinfo, -1)) {
|
||||
// no-op
|
||||
} elseif ('GET' !== $canonicalMethod) {
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
} else {
|
||||
return array_replace($ret, $this->redirect($rawPathinfo.'/', 'regex_trailing_slash_GET_method'));
|
||||
}
|
||||
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_GET_method');
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_GET_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_GET_method:
|
||||
|
||||
// regex_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/?$#s', $pathinfo, $matches)) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/head-method') && preg_match('#^/trailing/regex/head\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
if (substr($pathinfo, -1) !== '/') {
|
||||
return $this->redirect($pathinfo.'/', 'regex_trailing_slash_HEAD_method');
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_HEAD_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (0 === strpos($pathinfo, '/trailing/regex/post-method') && preg_match('#^/trailing/regex/post\\-method/(?P<param>[^/]++)/$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_trailing_slash_POST_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -149,34 +160,37 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_simple_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_GET_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_simple_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_HEAD_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
$ret = array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_simple_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return array('_route' => 'simple_not_trailing_slash_POST_method');
|
||||
return $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
|
|
@ -184,45 +198,52 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
|||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/regex')) {
|
||||
// regex_not_trailing_slash_no_methods
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/no-methods') && preg_match('#^/not\\-trailing/regex/no\\-methods/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_no_methods')), array ());
|
||||
}
|
||||
|
||||
// regex_not_trailing_slash_GET_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
$allow[] = 'GET';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/get-method') && preg_match('#^/not\\-trailing/regex/get\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
if (!in_array($canonicalMethod, array('GET'))) {
|
||||
$allow = array_merge($allow, array('GET'));
|
||||
goto not_regex_not_trailing_slash_GET_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_GET_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_GET_method:
|
||||
|
||||
// regex_not_trailing_slash_HEAD_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('HEAD' !== $requestMethod) {
|
||||
$allow[] = 'HEAD';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/head-method') && preg_match('#^/not\\-trailing/regex/head\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_regex_not_trailing_slash_HEAD_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_HEAD_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_HEAD_method:
|
||||
|
||||
// regex_not_trailing_slash_POST_method
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#s', $pathinfo, $matches)) {
|
||||
if ('POST' !== $canonicalMethod) {
|
||||
$allow[] = 'POST';
|
||||
if (0 === strpos($pathinfo, '/not-trailing/regex/post-method') && preg_match('#^/not\\-trailing/regex/post\\-method/(?P<param>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
$ret = $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
if (!in_array($requestMethod, array('POST'))) {
|
||||
$allow = array_merge($allow, array('POST'));
|
||||
goto not_regex_not_trailing_slash_POST_method;
|
||||
}
|
||||
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'regex_not_trailing_slash_POST_method')), array ());
|
||||
return $ret;
|
||||
}
|
||||
not_regex_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Fixtures/empty.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/empty.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/file_resource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/file_resource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/foo.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/foo.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/foo1.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/foo1.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/incomplete.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/incomplete.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/missing_id.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/missing_id.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/missing_path.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/missing_path.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/null_values.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/special_route_name.yml
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.php
vendored
Executable file → Normal file
2
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.php
vendored
Executable file → Normal file
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('blog_show', new Route(
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validpattern.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/validresource.yml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/withdoctype.xml
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Fixtures/withdoctype.xml
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php
vendored
Executable file → Normal file
12
pfosten/vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php
vendored
Executable file → Normal file
|
|
@ -12,11 +12,11 @@
|
|||
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class PhpGeneratorDumperTest extends TestCase
|
||||
{
|
||||
|
|
@ -46,8 +46,8 @@ class PhpGeneratorDumperTest extends TestCase
|
|||
|
||||
$this->routeCollection = new RouteCollection();
|
||||
$this->generatorDumper = new PhpGeneratorDumper($this->routeCollection);
|
||||
$this->testTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php';
|
||||
$this->largeTestTmpFilepath = sys_get_temp_dir().DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.large.php';
|
||||
$this->testTmpFilepath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.php';
|
||||
$this->largeTestTmpFilepath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_generator.'.$this->getName().'.large.php';
|
||||
@unlink($this->testTmpFilepath);
|
||||
@unlink($this->largeTestTmpFilepath);
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ class PhpGeneratorDumperTest extends TestCase
|
|||
|
||||
public function testDumpWithTooManyRoutes()
|
||||
{
|
||||
if (defined('HHVM_VERSION_ID')) {
|
||||
if (\defined('HHVM_VERSION_ID')) {
|
||||
$this->markTestSkipped('HHVM consumes too much memory on this test.');
|
||||
}
|
||||
|
||||
|
|
|
|||
36
pfosten/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php
vendored
Executable file → Normal file
36
pfosten/vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php
vendored
Executable file → Normal file
|
|
@ -12,11 +12,11 @@
|
|||
namespace Symfony\Component\Routing\Tests\Generator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class UrlGeneratorTest extends TestCase
|
||||
{
|
||||
|
|
@ -478,6 +478,38 @@ class UrlGeneratorTest extends TestCase
|
|||
$this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', array('locale' => 'EN'), UrlGeneratorInterface::NETWORK_PATH));
|
||||
}
|
||||
|
||||
public function testDefaultHostIsUsedWhenContextHostIsEmpty()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http')));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
|
||||
$this->assertSame('http://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testDefaultHostIsUsedWhenContextHostIsEmptyAndSchemeIsNot()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array('domain' => 'my.fallback.host'), array('domain' => '.+'), array(), '{domain}', array('http', 'https')));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
$generator->getContext()->setScheme('https');
|
||||
|
||||
$this->assertSame('https://my.fallback.host/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlFallbackToRelativeIfHostIsEmptyAndSchemeIsNot()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/route', array(), array(), array(), '', array('http', 'https')));
|
||||
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->getContext()->setHost('');
|
||||
$generator->getContext()->setScheme('https');
|
||||
|
||||
$this->assertSame('/app.php/route', $generator->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateNetworkPath()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com', array('http')));
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php
vendored
Executable file → Normal file
62
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php
vendored
Executable file → Normal file
62
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -127,17 +127,17 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
|
||||
$this->assertSame($routeData['path'], $route->getPath(), '->load preserves path annotation');
|
||||
$this->assertCount(
|
||||
count($routeData['requirements']),
|
||||
\count($routeData['requirements']),
|
||||
array_intersect_assoc($routeData['requirements'], $route->getRequirements()),
|
||||
'->load preserves requirements annotation'
|
||||
);
|
||||
$this->assertCount(
|
||||
count($routeData['options']),
|
||||
\count($routeData['options']),
|
||||
array_intersect_assoc($routeData['options'], $route->getOptions()),
|
||||
'->load preserves options annotation'
|
||||
);
|
||||
$this->assertCount(
|
||||
count($routeData['defaults']),
|
||||
\count($routeData['defaults']),
|
||||
$route->getDefaults(),
|
||||
'->load preserves defaults annotation'
|
||||
);
|
||||
|
|
@ -149,6 +149,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
public function testClassRouteLoad()
|
||||
{
|
||||
$classRouteData = array(
|
||||
'name' => 'prefix_',
|
||||
'path' => '/prefix',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
|
|
@ -173,7 +174,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
;
|
||||
|
||||
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass');
|
||||
$route = $routeCollection->get($methodRouteData['name']);
|
||||
$route = $routeCollection->get($classRouteData['name'].$methodRouteData['name']);
|
||||
|
||||
$this->assertSame($classRouteData['path'].$methodRouteData['path'], $route->getPath(), '->load concatenates class and method route path');
|
||||
$this->assertEquals(array_merge($classRouteData['schemes'], $methodRouteData['schemes']), $route->getSchemes(), '->load merges class and method route schemes');
|
||||
|
|
@ -190,9 +191,9 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
);
|
||||
|
||||
$this->reader
|
||||
->expects($this->exactly(2))
|
||||
->method('getClassAnnotation')
|
||||
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
|
||||
->expects($this->exactly(1))
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($classRouteData))))
|
||||
;
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
|
|
@ -204,8 +205,49 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
$route = $routeCollection->get($classRouteData['name']);
|
||||
|
||||
$this->assertSame($classRouteData['path'], $route->getPath(), '->load preserves class route path');
|
||||
$this->assertEquals(array_merge($classRouteData['schemes'], $classRouteData['schemes']), $route->getSchemes(), '->load preserves class route schemes');
|
||||
$this->assertEquals(array_merge($classRouteData['methods'], $classRouteData['methods']), $route->getMethods(), '->load preserves class route methods');
|
||||
$this->assertEquals($classRouteData['schemes'], $route->getSchemes(), '->load preserves class route schemes');
|
||||
$this->assertEquals($classRouteData['methods'], $route->getMethods(), '->load preserves class route methods');
|
||||
}
|
||||
|
||||
public function testInvokableClassMultipleRouteLoad()
|
||||
{
|
||||
$classRouteData1 = array(
|
||||
'name' => 'route1',
|
||||
'path' => '/1',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
|
||||
$classRouteData2 = array(
|
||||
'name' => 'route2',
|
||||
'path' => '/2',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
|
||||
$this->reader
|
||||
->expects($this->exactly(1))
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($classRouteData1), $this->getAnnotatedRoute($classRouteData2))))
|
||||
;
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
|
||||
$route = $routeCollection->get($classRouteData1['name']);
|
||||
|
||||
$this->assertSame($classRouteData1['path'], $route->getPath(), '->load preserves class route path');
|
||||
$this->assertEquals($classRouteData1['schemes'], $route->getSchemes(), '->load preserves class route schemes');
|
||||
$this->assertEquals($classRouteData1['methods'], $route->getMethods(), '->load preserves class route methods');
|
||||
|
||||
$route = $routeCollection->get($classRouteData2['name']);
|
||||
|
||||
$this->assertSame($classRouteData2['path'], $route->getPath(), '->load preserves class route path');
|
||||
$this->assertEquals($classRouteData2['schemes'], $route->getSchemes(), '->load preserves class route schemes');
|
||||
$this->assertEquals($classRouteData2['methods'], $route->getMethods(), '->load preserves class route methods');
|
||||
}
|
||||
|
||||
public function testInvokableClassWithMethodRouteLoad()
|
||||
|
|
@ -240,7 +282,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||
|
||||
$this->assertNull($route, '->load ignores class route');
|
||||
|
||||
$route = $routeCollection->get($methodRouteData['name']);
|
||||
$route = $routeCollection->get($classRouteData['name'].$methodRouteData['name']);
|
||||
|
||||
$this->assertSame($classRouteData['path'].$methodRouteData['path'], $route->getPath(), '->load concatenates class and method route path');
|
||||
$this->assertEquals(array_merge($classRouteData['schemes'], $methodRouteData['schemes']), $route->getSchemes(), '->load merges class and method route schemes');
|
||||
|
|
|
|||
39
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
vendored
Executable file → Normal file
39
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
|
||||
|
||||
class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
|
|
@ -29,7 +29,7 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
|||
|
||||
public function testLoad()
|
||||
{
|
||||
$this->reader->expects($this->exactly(4))->method('getClassAnnotation');
|
||||
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
|
|
@ -37,6 +37,12 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
|||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +51,6 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
|||
$this->expectAnnotationsToBeReadFrom(array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
|
||||
));
|
||||
|
||||
|
|
@ -55,6 +60,12 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
|||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
}
|
||||
|
||||
|
|
@ -69,12 +80,30 @@ class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
|||
$this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
|
||||
public function testItSupportsAnyAnnotation()
|
||||
{
|
||||
$this->assertTrue($this->loader->supports(__DIR__.'/../Fixtures/even-with-not-existing-folder', 'annotation'));
|
||||
}
|
||||
|
||||
public function testLoadFileIfLocatedResourceIsFile()
|
||||
{
|
||||
$this->reader->expects($this->exactly(1))->method('getClassAnnotation');
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
||||
}
|
||||
|
||||
private function expectAnnotationsToBeReadFrom(array $classes)
|
||||
{
|
||||
$this->reader->expects($this->exactly(count($classes)))
|
||||
$this->reader->expects($this->exactly(\count($classes)))
|
||||
->method('getClassAnnotation')
|
||||
->with($this->callback(function (\ReflectionClass $class) use ($classes) {
|
||||
return in_array($class->getName(), $classes);
|
||||
return \in_array($class->getName(), $classes);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php
vendored
Executable file → Normal file
13
pfosten/vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
|
||||
class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
|
|
@ -67,6 +67,17 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
|||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 7.0
|
||||
*/
|
||||
public function testLoadAnonymousClass()
|
||||
{
|
||||
$this->reader->expects($this->never())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->never())->method('getMethodAnnotations');
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php');
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$fixture = __DIR__.'/../Fixtures/annotated.php';
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php
vendored
Executable file → Normal file
6
pfosten/vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -11,11 +11,11 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
use Symfony\Component\Routing\Loader\DirectoryLoader;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class DirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php
vendored
Executable file → Normal file
50
pfosten/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php
vendored
Executable file → Normal file
50
pfosten/vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php
vendored
Executable file → Normal 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\PhpFileLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class PhpFileLoaderTest extends TestCase
|
||||
{
|
||||
|
|
@ -80,4 +83,51 @@ class PhpFileLoaderTest extends TestCase
|
|||
(string) $fileResource
|
||||
);
|
||||
}
|
||||
|
||||
public function testRoutingConfigurator()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures'));
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('php_dsl.php');
|
||||
|
||||
$expectedCollection = new RouteCollection();
|
||||
|
||||
$expectedCollection->add('foo', (new Route('/foo'))
|
||||
->setOptions(array('utf8' => true))
|
||||
->setCondition('abc')
|
||||
);
|
||||
$expectedCollection->add('buz', (new Route('/zub'))
|
||||
->setDefaults(array('_controller' => 'foo:act'))
|
||||
);
|
||||
$expectedCollection->add('c_bar', (new Route('/sub/pub/bar'))
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
);
|
||||
$expectedCollection->add('c_pub_buz', (new Route('/sub/pub/buz'))
|
||||
->setHost('host')
|
||||
->setRequirements(array('id' => '\d+'))
|
||||
);
|
||||
$expectedCollection->add('ouf', (new Route('/ouf'))
|
||||
->setSchemes(array('https'))
|
||||
->setMethods(array('GET'))
|
||||
->setDefaults(array('id' => 0))
|
||||
);
|
||||
|
||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl_sub.php')));
|
||||
$expectedCollection->addResource(new FileResource(realpath(__DIR__.'/../Fixtures/php_dsl.php')));
|
||||
|
||||
$this->assertEquals($expectedCollection, $routeCollection);
|
||||
}
|
||||
|
||||
public function testRoutingConfiguratorCanImportGlobPatterns()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures/glob'));
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('php_dsl.php');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('baz_route');
|
||||
$this->assertSame('AppBundle:Baz:view', $route->getDefault('_controller'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
95
pfosten/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php
vendored
Executable file → Normal file
95
pfosten/vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -287,4 +287,99 @@ class XmlFileLoaderTest extends TestCase
|
|||
$route->getDefault('map')
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerAttribute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
|
||||
$this->assertSame('AppBundle:Homepage:show', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithoutControllerAttribute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
|
||||
$this->assertNull($route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerSetInDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.xml');
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
|
||||
$this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for "app_blog"/
|
||||
*/
|
||||
public function testOverrideControllerInDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('override_defaults.xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilesImportingRoutesWithControllers
|
||||
*/
|
||||
public function testImportRouteWithController($file)
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load($file);
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function provideFilesImportingRoutesWithControllers()
|
||||
{
|
||||
yield array('import_controller.xml');
|
||||
yield array('import__controller.xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" attribute and the defaults key "_controller" for the "import" tag/
|
||||
*/
|
||||
public function testImportWithOverriddenController()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('import_override_defaults.xml');
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingSingleFile()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_single.xml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingMultipleFiles()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_multiple.xml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('baz_route');
|
||||
$this->assertSame('AppBundle:Baz:view', $route->getDefault('_controller'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
97
pfosten/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php
vendored
Executable file → Normal file
97
pfosten/vendor/symfony/routing/Tests/Loader/YamlFileLoaderTest.php
vendored
Executable file → Normal file
|
|
@ -13,8 +13,8 @@ namespace Symfony\Component\Routing\Tests\Loader;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
|
||||
class YamlFileLoaderTest extends TestCase
|
||||
{
|
||||
|
|
@ -108,4 +108,99 @@ class YamlFileLoaderTest extends TestCase
|
|||
$this->assertSame('context.getMethod() == "POST"', $route->getCondition());
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
|
||||
$this->assertSame('AppBundle:Homepage:show', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithoutControllerAttribute()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
|
||||
$this->assertNull($route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testLoadRouteWithControllerSetInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load('routing.yml');
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
|
||||
$this->assertSame('AppBundle:Blog:list', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "app_blog"/
|
||||
*/
|
||||
public function testOverrideControllerInDefaults()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('override_defaults.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFilesImportingRoutesWithControllers
|
||||
*/
|
||||
public function testImportRouteWithController($file)
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$routeCollection = $loader->load($file);
|
||||
|
||||
$route = $routeCollection->get('app_homepage');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_blog');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('app_logout');
|
||||
$this->assertSame('FrameworkBundle:Template:template', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function provideFilesImportingRoutesWithControllers()
|
||||
{
|
||||
yield array('import_controller.yml');
|
||||
yield array('import__controller.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessageRegExp /The routing file "[^"]*" must not specify both the "controller" key and the defaults key "_controller" for "_static"/
|
||||
*/
|
||||
public function testImportWithOverriddenController()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/controller')));
|
||||
$loader->load('import_override_defaults.yml');
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingSingleFile()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_single.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
}
|
||||
|
||||
public function testImportRouteWithGlobMatchingMultipleFiles()
|
||||
{
|
||||
$loader = new YamlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures/glob')));
|
||||
$routeCollection = $loader->load('import_multiple.yml');
|
||||
|
||||
$route = $routeCollection->get('bar_route');
|
||||
$this->assertSame('AppBundle:Bar:view', $route->getDefault('_controller'));
|
||||
|
||||
$route = $routeCollection->get('baz_route');
|
||||
$this->assertSame('AppBundle:Baz:view', $route->getDefault('_controller'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/DumperCollectionTest.php
vendored
Executable file → Normal file
84
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
vendored
Executable file → Normal file
84
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
vendored
Executable file → Normal file
|
|
@ -13,11 +13,39 @@ namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
|
||||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class PhpMatcherDumperTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $matcherClass;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $dumpPath;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->matcherClass = uniqid('ProjectUrlMatcher');
|
||||
$this->dumpPath = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'php_matcher.'.$this->matcherClass.'.php';
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
@unlink($this->dumpPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
|
|
@ -36,6 +64,23 @@ class PhpMatcherDumperTest extends TestCase
|
|||
$dumper->dump();
|
||||
}
|
||||
|
||||
public function testRedirectPreservesUrlEncoding()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo:bar/'));
|
||||
|
||||
$class = $this->generateDumpedMatcher($collection, true);
|
||||
|
||||
$matcher = $this->getMockBuilder($class)
|
||||
->setMethods(array('redirect'))
|
||||
->setConstructorArgs(array(new RequestContext()))
|
||||
->getMock();
|
||||
|
||||
$matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/', 'foo')->willReturn(array());
|
||||
|
||||
$matcher->match('/foo%3Abar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getRouteCollections
|
||||
*/
|
||||
|
|
@ -297,10 +342,19 @@ class PhpMatcherDumperTest extends TestCase
|
|||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('HEAD', 'GET')
|
||||
));
|
||||
$headMatchCasesCollection->add('get_and_head', new Route(
|
||||
'/get_and_head',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('GET', 'HEAD')
|
||||
));
|
||||
$headMatchCasesCollection->add('post_and_head', new Route(
|
||||
'/post_and_get',
|
||||
'/post_and_head',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
|
|
@ -365,6 +419,7 @@ class PhpMatcherDumperTest extends TestCase
|
|||
$trailingSlashCollection->add('regex_not_trailing_slash_POST_method', new Route('/not-trailing/regex/post-method/{param}', array(), array(), array(), '', array(), array('POST')));
|
||||
|
||||
return array(
|
||||
array(new RouteCollection(), 'url_matcher0.php', array()),
|
||||
array($collection, 'url_matcher1.php', array()),
|
||||
array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),
|
||||
array($rootprefixCollection, 'url_matcher3.php', array()),
|
||||
|
|
@ -374,4 +429,31 @@ class PhpMatcherDumperTest extends TestCase
|
|||
array($trailingSlashCollection, 'url_matcher7.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dumper
|
||||
*/
|
||||
private function generateDumpedMatcher(RouteCollection $collection, $redirectableStub = false)
|
||||
{
|
||||
$options = array('class' => $this->matcherClass);
|
||||
|
||||
if ($redirectableStub) {
|
||||
$options['base_class'] = '\Symfony\Component\Routing\Tests\Matcher\Dumper\RedirectableUrlMatcherStub';
|
||||
}
|
||||
|
||||
$dumper = new PhpMatcherDumper($collection);
|
||||
$code = $dumper->dump($options);
|
||||
|
||||
file_put_contents($this->dumpPath, $code);
|
||||
include $this->dumpPath;
|
||||
|
||||
return $this->matcherClass;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class RedirectableUrlMatcherStub extends UrlMatcher implements RedirectableUrlMatcherInterface
|
||||
{
|
||||
public function redirect($path, $route, $scheme = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/Matcher/Dumper/StaticPrefixCollectionTest.php
vendored
Executable file → Normal file
76
pfosten/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php
vendored
Executable file → Normal file
76
pfosten/vendor/symfony/routing/Tests/Matcher/RedirectableUrlMatcherTest.php
vendored
Executable file → Normal file
|
|
@ -11,20 +11,19 @@
|
|||
|
||||
namespace Symfony\Component\Routing\Tests\Matcher;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
class RedirectableUrlMatcherTest extends TestCase
|
||||
class RedirectableUrlMatcherTest extends UrlMatcherTest
|
||||
{
|
||||
public function testRedirectWhenNoSlash()
|
||||
public function testMissingTrailingSlash()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/'));
|
||||
|
||||
$matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext()));
|
||||
$matcher->expects($this->once())->method('redirect');
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->expects($this->once())->method('redirect')->will($this->returnValue(array()));
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ class RedirectableUrlMatcherTest extends TestCase
|
|||
|
||||
$context = new RequestContext();
|
||||
$context->setMethod('POST');
|
||||
$matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, $context));
|
||||
$matcher = $this->getUrlMatcher($coll, $context);
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +46,7 @@ class RedirectableUrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array('FTP', 'HTTPS')));
|
||||
|
||||
$matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext()));
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher
|
||||
->expects($this->once())
|
||||
->method('redirect')
|
||||
|
|
@ -57,16 +56,69 @@ class RedirectableUrlMatcherTest extends TestCase
|
|||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
public function testNoSchemaRedirectIfOnOfMultipleSchemesMatches()
|
||||
public function testNoSchemaRedirectIfOneOfMultipleSchemesMatches()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https', 'http')));
|
||||
|
||||
$matcher = $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($coll, new RequestContext()));
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher
|
||||
->expects($this->never())
|
||||
->method('redirect')
|
||||
;
|
||||
->method('redirect');
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
public function testSchemeRedirectWithParams()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{bar}', array(), array(), array(), '', array('https')));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher
|
||||
->expects($this->once())
|
||||
->method('redirect')
|
||||
->with('/foo/baz', 'foo', 'https')
|
||||
->will($this->returnValue(array('redirect' => 'value')))
|
||||
;
|
||||
$this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'), $matcher->match('/foo/baz'));
|
||||
}
|
||||
|
||||
public function testSlashRedirectWithParams()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{bar}/'));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher
|
||||
->expects($this->once())
|
||||
->method('redirect')
|
||||
->with('/foo/baz/', 'foo', null)
|
||||
->will($this->returnValue(array('redirect' => 'value')))
|
||||
;
|
||||
$this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'redirect' => 'value'), $matcher->match('/foo/baz'));
|
||||
}
|
||||
|
||||
public function testRedirectPreservesUrlEncoding()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo:bar/'));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->expects($this->once())->method('redirect')->with('/foo%3Abar/')->willReturn(array());
|
||||
$matcher->match('/foo%3Abar');
|
||||
}
|
||||
|
||||
public function testSchemeRequirement()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https')));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext());
|
||||
$matcher->expects($this->once())->method('redirect')->with('/foo', 'foo', 'https')->willReturn(array());
|
||||
$this->assertSame(array('_route' => 'foo'), $matcher->match('/foo'));
|
||||
}
|
||||
|
||||
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
|
||||
{
|
||||
return $this->getMockForAbstractClass('Symfony\Component\Routing\Matcher\RedirectableUrlMatcher', array($routes, $context ?: new RequestContext()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/routing/Tests/Matcher/TraceableUrlMatcherTest.php
vendored
Executable file → Normal file
|
|
@ -13,10 +13,10 @@ namespace Symfony\Component\Routing\Tests\Matcher;
|
|||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
|
||||
|
||||
class TraceableUrlMatcherTest extends TestCase
|
||||
{
|
||||
|
|
|
|||
169
pfosten/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php
vendored
Executable file → Normal file
169
pfosten/vendor/symfony/routing/Tests/Matcher/UrlMatcherTest.php
vendored
Executable file → Normal file
|
|
@ -15,9 +15,9 @@ use PHPUnit\Framework\TestCase;
|
|||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
class UrlMatcherTest extends TestCase
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertInternalType('array', $matcher->match('/foo'));
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('post')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
try {
|
||||
$matcher->match('/foo');
|
||||
|
|
@ -45,12 +45,27 @@ class UrlMatcherTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public function testMethodNotAllowedOnRoot()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/', array(), array(), array(), '', array(), array('GET')));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'POST'));
|
||||
|
||||
try {
|
||||
$matcher->match('/');
|
||||
$this->fail();
|
||||
} catch (MethodNotAllowedException $e) {
|
||||
$this->assertEquals(array('GET'), $e->getAllowedMethods());
|
||||
}
|
||||
}
|
||||
|
||||
public function testHeadAllowedWhenRequirementContainsGet()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('get')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'head'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'head'));
|
||||
$this->assertInternalType('array', $matcher->match('/foo'));
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +75,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll->add('foo1', new Route('/foo', array(), array(), array(), '', array(), array('post')));
|
||||
$coll->add('foo2', new Route('/foo', array(), array(), array(), '', array(), array('put', 'delete')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
try {
|
||||
$matcher->match('/foo');
|
||||
|
|
@ -75,7 +90,7 @@ class UrlMatcherTest extends TestCase
|
|||
// test the patterns are matched and parameters are returned
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo/{bar}'));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
try {
|
||||
$matcher->match('/no-match');
|
||||
$this->fail();
|
||||
|
|
@ -86,17 +101,17 @@ class UrlMatcherTest extends TestCase
|
|||
// test that defaults are merged
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo/{bar}', array('def' => 'test')));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'foo', 'bar' => 'baz', 'def' => 'test'), $matcher->match('/foo/baz'));
|
||||
|
||||
// test that route "method" is ignored if no method is given in the context
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo', array(), array(), array(), '', array(), array('get', 'head')));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertInternalType('array', $matcher->match('/foo'));
|
||||
|
||||
// route does not match with POST method context
|
||||
$matcher = new UrlMatcher($collection, new RequestContext('', 'post'));
|
||||
$matcher = $this->getUrlMatcher($collection, new RequestContext('', 'post'));
|
||||
try {
|
||||
$matcher->match('/foo');
|
||||
$this->fail();
|
||||
|
|
@ -104,28 +119,28 @@ class UrlMatcherTest extends TestCase
|
|||
}
|
||||
|
||||
// route does match with GET or HEAD method context
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertInternalType('array', $matcher->match('/foo'));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext('', 'head'));
|
||||
$matcher = $this->getUrlMatcher($collection, new RequestContext('', 'head'));
|
||||
$this->assertInternalType('array', $matcher->match('/foo'));
|
||||
|
||||
// route with an optional variable as the first segment
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('bar', new Route('/{bar}/foo', array('bar' => 'bar'), array('bar' => 'foo|bar')));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/bar/foo'));
|
||||
$this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo/foo'));
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('bar', new Route('/{bar}', array('bar' => 'bar'), array('bar' => 'foo|bar')));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'bar', 'bar' => 'foo'), $matcher->match('/foo'));
|
||||
$this->assertEquals(array('_route' => 'bar', 'bar' => 'bar'), $matcher->match('/'));
|
||||
|
||||
// route with only optional variables
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('bar', new Route('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar'), array()));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'bar', 'foo' => 'foo', 'bar' => 'bar'), $matcher->match('/'));
|
||||
$this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'bar'), $matcher->match('/a'));
|
||||
$this->assertEquals(array('_route' => 'bar', 'foo' => 'a', 'bar' => 'b'), $matcher->match('/a/b'));
|
||||
|
|
@ -138,7 +153,7 @@ class UrlMatcherTest extends TestCase
|
|||
$collection->addPrefix('/b');
|
||||
$collection->addPrefix('/a');
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'foo', 'foo' => 'foo'), $matcher->match('/a/b/foo'));
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +164,7 @@ class UrlMatcherTest extends TestCase
|
|||
$collection->addPrefix('/b');
|
||||
$collection->addPrefix('/{_locale}');
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_locale' => 'fr', '_route' => 'foo', 'foo' => 'foo'), $matcher->match('/fr/b/foo'));
|
||||
}
|
||||
|
||||
|
|
@ -158,17 +173,29 @@ class UrlMatcherTest extends TestCase
|
|||
$collection = new RouteCollection();
|
||||
$collection->add('$péß^a|', new Route('/bar'));
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => '$péß^a|'), $matcher->match('/bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
|
||||
*/
|
||||
public function testTrailingEncodedNewlineIsNotOverlooked()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo'));
|
||||
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$matcher->match('/foo%0a');
|
||||
}
|
||||
|
||||
public function testMatchNonAlpha()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$chars = '!"$%éà &\'()*+,./:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[]^_`abcdefghijklmnopqrstuvwxyz{|}~-';
|
||||
$collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '['.preg_quote($chars).']+'), array('utf8' => true)));
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.rawurlencode($chars).'/bar'));
|
||||
$this->assertEquals(array('_route' => 'foo', 'foo' => $chars), $matcher->match('/'.strtr($chars, array('%' => '%25')).'/bar'));
|
||||
}
|
||||
|
|
@ -178,7 +205,7 @@ class UrlMatcherTest extends TestCase
|
|||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/{foo}/bar', array(), array('foo' => '.+')));
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
$this->assertEquals(array('_route' => 'foo', 'foo' => "\n"), $matcher->match('/'.urlencode("\n").'/bar'), 'linefeed character is matched');
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +219,7 @@ class UrlMatcherTest extends TestCase
|
|||
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
|
||||
$this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo1'));
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\ResourceNotFoundException');
|
||||
|
|
@ -205,12 +232,12 @@ class UrlMatcherTest extends TestCase
|
|||
$coll->add('foo', new Route('/foo/{foo}'));
|
||||
$coll->add('bar', new Route('/foo/bar/{foo}'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('foo' => 'bar', '_route' => 'bar'), $matcher->match('/foo/bar/bar'));
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/{bar}'));
|
||||
$matcher = new UrlMatcher($collection, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($collection);
|
||||
try {
|
||||
$matcher->match('/');
|
||||
$this->fail();
|
||||
|
|
@ -223,7 +250,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{page}.{_format}', array('page' => 'index', '_format' => 'html')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('page' => 'my-page', '_format' => 'xml', '_route' => 'test'), $matcher->match('/my-page.xml'));
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +259,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{foo}-{bar}-', array(), array('foo' => '.+', 'bar' => '.+')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('foo' => 'text1-text2-text3', 'bar' => 'text4', '_route' => 'test'), $matcher->match('/text1-text2-text3-text4-'));
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +268,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => 'y|Y')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
// 'w' eagerly matches as much as possible and the other variables match the remaining chars.
|
||||
// This also shows that the variables w-z must all exclude the separating char (the dot '.' in this case) by default requirement.
|
||||
// Otherwise they would also consume '.xml' and _format would never match as it's an optional variable.
|
||||
|
|
@ -260,7 +287,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/get{what}', array('what' => 'All')));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
$this->assertEquals(array('what' => 'All', '_route' => 'test'), $matcher->match('/get'));
|
||||
$this->assertEquals(array('what' => 'Sites', '_route' => 'test'), $matcher->match('/getSites'));
|
||||
|
|
@ -275,7 +302,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/get{what}Suffix'));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
$this->assertEquals(array('what' => 'Sites', '_route' => 'test'), $matcher->match('/getSitesSuffix'));
|
||||
}
|
||||
|
|
@ -284,7 +311,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{page}.{_format}'));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
$this->assertEquals(array('page' => 'index', '_format' => 'mobile.html', '_route' => 'test'), $matcher->match('/index.mobile.html'));
|
||||
}
|
||||
|
|
@ -296,7 +323,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{page}.{_format}'));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
$matcher->match('/index.sl/ash');
|
||||
}
|
||||
|
|
@ -308,7 +335,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('test', new Route('/{page}.{_format}', array(), array('_format' => 'html|xml')));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
|
||||
$matcher->match('/do.t.html');
|
||||
}
|
||||
|
|
@ -320,7 +347,7 @@ class UrlMatcherTest extends TestCase
|
|||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo', array(), array(), array(), '', array('https')));
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
|
|
@ -333,16 +360,26 @@ class UrlMatcherTest extends TestCase
|
|||
$route = new Route('/foo');
|
||||
$route->setCondition('context.getMethod() == "POST"');
|
||||
$coll->add('foo', $route);
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->match('/foo');
|
||||
}
|
||||
|
||||
public function testRequestCondition()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$route = new Route('/foo/{bar}');
|
||||
$route->setCondition('request.getBaseUrl() == "/sub/front.php" and request.getPathInfo() == "/foo/bar"');
|
||||
$coll->add('foo', $route);
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('/sub/front.php'));
|
||||
$this->assertEquals(array('bar' => 'bar', '_route' => 'foo'), $matcher->match('/foo/bar'));
|
||||
}
|
||||
|
||||
public function testDecodeOnce()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{foo}'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('foo' => 'bar%23', '_route' => 'foo'), $matcher->match('/foo/bar%2523'));
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +395,7 @@ class UrlMatcherTest extends TestCase
|
|||
|
||||
$coll->addCollection($subColl);
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('_route' => 'bar'), $matcher->match('/new'));
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +404,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar'));
|
||||
}
|
||||
|
||||
|
|
@ -378,10 +415,10 @@ class UrlMatcherTest extends TestCase
|
|||
$coll->add('bar', new Route('/bar/{foo}', array(), array(), array(), '{locale}.example.net'));
|
||||
$coll->setHost('{locale}.example.com');
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$this->assertEquals(array('foo' => 'bar', '_route' => 'foo', 'locale' => 'en'), $matcher->match('/foo/bar'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$this->assertEquals(array('foo' => 'bar', '_route' => 'bar', 'locale' => 'en'), $matcher->match('/bar/bar'));
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +430,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/foo/{foo}', array(), array(), array(), '{locale}.example.com'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'example.com'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'GET', 'example.com'));
|
||||
$matcher->match('/foo/bar');
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +442,7 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/locale', array(), array('locale' => 'EN|FR|DE')));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext());
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->match('/en');
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +451,59 @@ class UrlMatcherTest extends TestCase
|
|||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/', array(), array('locale' => 'EN|FR|DE'), array(), '{locale}.example.com'));
|
||||
|
||||
$matcher = new UrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'GET', 'en.example.com'));
|
||||
$this->assertEquals(array('_route' => 'foo', 'locale' => 'en'), $matcher->match('/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\NoConfigurationException
|
||||
*/
|
||||
public function testNoConfiguration()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->match('/');
|
||||
}
|
||||
|
||||
public function testNestedCollections()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
|
||||
$subColl = new RouteCollection();
|
||||
$subColl->add('a', new Route('/a'));
|
||||
$subColl->add('b', new Route('/b'));
|
||||
$subColl->add('c', new Route('/c'));
|
||||
$subColl->addPrefix('/p');
|
||||
$coll->addCollection($subColl);
|
||||
|
||||
$coll->add('baz', new Route('/{baz}'));
|
||||
|
||||
$subColl = new RouteCollection();
|
||||
$subColl->add('buz', new Route('/buz'));
|
||||
$subColl->addPrefix('/prefix');
|
||||
$coll->addCollection($subColl);
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$this->assertEquals(array('_route' => 'a'), $matcher->match('/p/a'));
|
||||
$this->assertEquals(array('_route' => 'baz', 'baz' => 'p'), $matcher->match('/p'));
|
||||
$this->assertEquals(array('_route' => 'buz'), $matcher->match('/prefix/buz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException
|
||||
*/
|
||||
public function testSchemeAndMethodMismatch()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/', array(), array(), array(), null, array('https'), array('POST')));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll);
|
||||
$matcher->match('/');
|
||||
}
|
||||
|
||||
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
|
||||
{
|
||||
return new UrlMatcher($routes, $context ?: new RequestContext());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
pfosten/vendor/symfony/routing/Tests/RequestContextTest.php
vendored
Executable file → Normal file
0
pfosten/vendor/symfony/routing/Tests/RequestContextTest.php
vendored
Executable file → Normal file
39
pfosten/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php
vendored
Executable file → Normal file
39
pfosten/vendor/symfony/routing/Tests/RouteCollectionBuilderTest.php
vendored
Executable file → Normal file
|
|
@ -12,7 +12,9 @@
|
|||
namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
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;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
|
@ -59,7 +61,18 @@ class RouteCollectionBuilderTest extends TestCase
|
|||
$this->assertCount(1, $addedCollection->getResources());
|
||||
|
||||
// make sure the routes were imported into the top-level builder
|
||||
$routeCollection = $routes->build();
|
||||
$this->assertCount(1, $routes->build());
|
||||
$this->assertCount(1, $routeCollection->getResources());
|
||||
}
|
||||
|
||||
public function testImportAddResources()
|
||||
{
|
||||
$routeCollectionBuilder = new RouteCollectionBuilder(new YamlFileLoader(new FileLocator(array(__DIR__.'/Fixtures/'))));
|
||||
$routeCollectionBuilder->import('file_resource.yml');
|
||||
$routeCollection = $routeCollectionBuilder->build();
|
||||
|
||||
$this->assertCount(1, $routeCollection->getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -322,4 +335,30 @@ class RouteCollectionBuilderTest extends TestCase
|
|||
// there are 2 routes (i.e. with non-conflicting names)
|
||||
$this->assertCount(3, $collection->all());
|
||||
}
|
||||
|
||||
public function testAddsThePrefixOnlyOnceWhenLoadingMultipleCollections()
|
||||
{
|
||||
$firstCollection = new RouteCollection();
|
||||
$firstCollection->add('a', new Route('/a'));
|
||||
|
||||
$secondCollection = new RouteCollection();
|
||||
$secondCollection->add('b', new Route('/b'));
|
||||
|
||||
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
|
||||
$loader->expects($this->any())
|
||||
->method('supports')
|
||||
->will($this->returnValue(true));
|
||||
$loader
|
||||
->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValue(array($firstCollection, $secondCollection)));
|
||||
|
||||
$routeCollectionBuilder = new RouteCollectionBuilder($loader);
|
||||
$routeCollectionBuilder->import('/directory/recurse/*', '/other/', 'glob');
|
||||
$routes = $routeCollectionBuilder->build()->all();
|
||||
|
||||
$this->assertCount(2, $routes);
|
||||
$this->assertEquals('/other/a', $routes['a']->getPath());
|
||||
$this->assertEquals('/other/b', $routes['b']->getPath());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
pfosten/vendor/symfony/routing/Tests/RouteCollectionTest.php
vendored
Executable file → Normal file
4
pfosten/vendor/symfony/routing/Tests/RouteCollectionTest.php
vendored
Executable file → Normal file
|
|
@ -12,9 +12,9 @@
|
|||
namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class RouteCollectionTest extends TestCase
|
||||
{
|
||||
|
|
|
|||
56
pfosten/vendor/symfony/routing/Tests/RouteCompilerTest.php
vendored
Executable file → Normal file
56
pfosten/vendor/symfony/routing/Tests/RouteCompilerTest.php
vendored
Executable file → Normal file
|
|
@ -38,7 +38,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Static route',
|
||||
array('/foo'),
|
||||
'/foo', '#^/foo$#s', array(), array(
|
||||
'/foo', '#^/foo$#sD', array(), array(
|
||||
array('text', '/foo'),
|
||||
),
|
||||
),
|
||||
|
|
@ -46,7 +46,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a variable',
|
||||
array('/foo/{bar}'),
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)$#s', array('bar'), array(
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)$#sD', array('bar'), array(
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
),
|
||||
|
|
@ -55,7 +55,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a variable that has a default value',
|
||||
array('/foo/{bar}', array('bar' => 'bar')),
|
||||
'/foo', '#^/foo(?:/(?P<bar>[^/]++))?$#s', array('bar'), array(
|
||||
'/foo', '#^/foo(?:/(?P<bar>[^/]++))?$#sD', array('bar'), array(
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
),
|
||||
|
|
@ -64,7 +64,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with several variables',
|
||||
array('/foo/{bar}/{foobar}'),
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#sD', array('bar', 'foobar'), array(
|
||||
array('variable', '/', '[^/]++', 'foobar'),
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
|
|
@ -74,7 +74,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with several variables that have default values',
|
||||
array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')),
|
||||
'/foo', '#^/foo(?:/(?P<bar>[^/]++)(?:/(?P<foobar>[^/]++))?)?$#s', array('bar', 'foobar'), array(
|
||||
'/foo', '#^/foo(?:/(?P<bar>[^/]++)(?:/(?P<foobar>[^/]++))?)?$#sD', array('bar', 'foobar'), array(
|
||||
array('variable', '/', '[^/]++', 'foobar'),
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
|
|
@ -84,7 +84,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with several variables but some of them have no default values',
|
||||
array('/foo/{bar}/{foobar}', array('bar' => 'bar')),
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#s', array('bar', 'foobar'), array(
|
||||
'/foo', '#^/foo/(?P<bar>[^/]++)/(?P<foobar>[^/]++)$#sD', array('bar', 'foobar'), array(
|
||||
array('variable', '/', '[^/]++', 'foobar'),
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
|
|
@ -94,7 +94,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with an optional variable as the first segment',
|
||||
array('/{bar}', array('bar' => 'bar')),
|
||||
'', '#^/(?P<bar>[^/]++)?$#s', array('bar'), array(
|
||||
'', '#^/(?P<bar>[^/]++)?$#sD', array('bar'), array(
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
),
|
||||
),
|
||||
|
|
@ -102,7 +102,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a requirement of 0',
|
||||
array('/{bar}', array('bar' => null), array('bar' => '0')),
|
||||
'', '#^/(?P<bar>0)?$#s', array('bar'), array(
|
||||
'', '#^/(?P<bar>0)?$#sD', array('bar'), array(
|
||||
array('variable', '/', '0', 'bar'),
|
||||
),
|
||||
),
|
||||
|
|
@ -110,7 +110,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with an optional variable as the first segment with requirements',
|
||||
array('/{bar}', array('bar' => 'bar'), array('bar' => '(foo|bar)')),
|
||||
'', '#^/(?P<bar>(foo|bar))?$#s', array('bar'), array(
|
||||
'', '#^/(?P<bar>(foo|bar))?$#sD', array('bar'), array(
|
||||
array('variable', '/', '(foo|bar)', 'bar'),
|
||||
),
|
||||
),
|
||||
|
|
@ -118,7 +118,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with only optional variables',
|
||||
array('/{foo}/{bar}', array('foo' => 'foo', 'bar' => 'bar')),
|
||||
'', '#^/(?P<foo>[^/]++)?(?:/(?P<bar>[^/]++))?$#s', array('foo', 'bar'), array(
|
||||
'', '#^/(?P<foo>[^/]++)?(?:/(?P<bar>[^/]++))?$#sD', array('foo', 'bar'), array(
|
||||
array('variable', '/', '[^/]++', 'bar'),
|
||||
array('variable', '/', '[^/]++', 'foo'),
|
||||
),
|
||||
|
|
@ -127,7 +127,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a variable in last position',
|
||||
array('/foo-{bar}'),
|
||||
'/foo-', '#^/foo\-(?P<bar>[^/]++)$#s', array('bar'), array(
|
||||
'/foo-', '#^/foo\-(?P<bar>[^/]++)$#sD', array('bar'), array(
|
||||
array('variable', '-', '[^/]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
),
|
||||
|
|
@ -136,7 +136,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with nested placeholders',
|
||||
array('/{static{var}static}'),
|
||||
'/{static', '#^/\{static(?P<var>[^/]+)static\}$#s', array('var'), array(
|
||||
'/{static', '#^/\{static(?P<var>[^/]+)static\}$#sD', array('var'), array(
|
||||
array('text', 'static}'),
|
||||
array('variable', '', '[^/]+', 'var'),
|
||||
array('text', '/{static'),
|
||||
|
|
@ -146,7 +146,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route without separator between variables',
|
||||
array('/{w}{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '(y|Y)')),
|
||||
'', '#^/(?P<w>[^/\.]+)(?P<x>[^/\.]+)(?P<y>(y|Y))(?:(?P<z>[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#s', array('w', 'x', 'y', 'z', '_format'), array(
|
||||
'', '#^/(?P<w>[^/\.]+)(?P<x>[^/\.]+)(?P<y>(y|Y))(?:(?P<z>[^/\.]++)(?:\.(?P<_format>[^/]++))?)?$#sD', array('w', 'x', 'y', 'z', '_format'), array(
|
||||
array('variable', '.', '[^/]++', '_format'),
|
||||
array('variable', '', '[^/\.]++', 'z'),
|
||||
array('variable', '', '(y|Y)', 'y'),
|
||||
|
|
@ -158,7 +158,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a format',
|
||||
array('/foo/{bar}.{_format}'),
|
||||
'/foo', '#^/foo/(?P<bar>[^/\.]++)\.(?P<_format>[^/]++)$#s', array('bar', '_format'), array(
|
||||
'/foo', '#^/foo/(?P<bar>[^/\.]++)\.(?P<_format>[^/]++)$#sD', array('bar', '_format'), array(
|
||||
array('variable', '.', '[^/]++', '_format'),
|
||||
array('variable', '/', '[^/\.]++', 'bar'),
|
||||
array('text', '/foo'),
|
||||
|
|
@ -168,7 +168,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Static non UTF-8 route',
|
||||
array("/fo\xE9"),
|
||||
"/fo\xE9", "#^/fo\xE9$#s", array(), array(
|
||||
"/fo\xE9", "#^/fo\xE9$#sD", array(), array(
|
||||
array('text', "/fo\xE9"),
|
||||
),
|
||||
),
|
||||
|
|
@ -176,7 +176,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with an explicit UTF-8 requirement',
|
||||
array('/{bar}', array('bar' => null), array('bar' => '.'), array('utf8' => true)),
|
||||
'', '#^/(?P<bar>.)?$#su', array('bar'), array(
|
||||
'', '#^/(?P<bar>.)?$#sDu', array('bar'), array(
|
||||
array('variable', '/', '.', 'bar', true),
|
||||
),
|
||||
),
|
||||
|
|
@ -206,7 +206,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Static UTF-8 route',
|
||||
array('/foé'),
|
||||
'/foé', '#^/foé$#su', array(), array(
|
||||
'/foé', '#^/foé$#sDu', array(), array(
|
||||
array('text', '/foé'),
|
||||
),
|
||||
'patterns',
|
||||
|
|
@ -215,7 +215,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with an implicit UTF-8 requirement',
|
||||
array('/{bar}', array('bar' => null), array('bar' => 'é')),
|
||||
'', '#^/(?P<bar>é)?$#su', array('bar'), array(
|
||||
'', '#^/(?P<bar>é)?$#sDu', array('bar'), array(
|
||||
array('variable', '/', 'é', 'bar', true),
|
||||
),
|
||||
'requirements',
|
||||
|
|
@ -224,7 +224,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a UTF-8 class requirement',
|
||||
array('/{bar}', array('bar' => null), array('bar' => '\pM')),
|
||||
'', '#^/(?P<bar>\pM)?$#su', array('bar'), array(
|
||||
'', '#^/(?P<bar>\pM)?$#sDu', array('bar'), array(
|
||||
array('variable', '/', '\pM', 'bar', true),
|
||||
),
|
||||
'requirements',
|
||||
|
|
@ -233,7 +233,7 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with a UTF-8 separator',
|
||||
array('/foo/{bar}§{_format}', array(), array(), array('compiler_class' => Utf8RouteCompiler::class)),
|
||||
'/foo', '#^/foo/(?P<bar>[^/§]++)§(?P<_format>[^/]++)$#su', array('bar', '_format'), array(
|
||||
'/foo', '#^/foo/(?P<bar>[^/§]++)§(?P<_format>[^/]++)$#sDu', array('bar', '_format'), array(
|
||||
array('variable', '§', '[^/]++', '_format', true),
|
||||
array('variable', '/', '[^/§]++', 'bar', true),
|
||||
array('text', '/foo'),
|
||||
|
|
@ -327,21 +327,21 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with host pattern',
|
||||
array('/hello', array(), array(), array(), 'www.example.com'),
|
||||
'/hello', '#^/hello$#s', array(), array(), array(
|
||||
'/hello', '#^/hello$#sD', array(), array(), array(
|
||||
array('text', '/hello'),
|
||||
),
|
||||
'#^www\.example\.com$#si', array(), array(
|
||||
'#^www\.example\.com$#sDi', array(), array(
|
||||
array('text', 'www.example.com'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'Route with host pattern and some variables',
|
||||
array('/hello/{name}', array(), array(), array(), 'www.example.{tld}'),
|
||||
'/hello', '#^/hello/(?P<name>[^/]++)$#s', array('tld', 'name'), array('name'), array(
|
||||
'/hello', '#^/hello/(?P<name>[^/]++)$#sD', array('tld', 'name'), array('name'), array(
|
||||
array('variable', '/', '[^/]++', 'name'),
|
||||
array('text', '/hello'),
|
||||
),
|
||||
'#^www\.example\.(?P<tld>[^\.]++)$#si', array('tld'), array(
|
||||
'#^www\.example\.(?P<tld>[^\.]++)$#sDi', array('tld'), array(
|
||||
array('variable', '.', '[^\.]++', 'tld'),
|
||||
array('text', 'www.example'),
|
||||
),
|
||||
|
|
@ -349,10 +349,10 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with variable at beginning of host',
|
||||
array('/hello', array(), array(), array(), '{locale}.example.{tld}'),
|
||||
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
|
||||
'/hello', '#^/hello$#sD', array('locale', 'tld'), array(), array(
|
||||
array('text', '/hello'),
|
||||
),
|
||||
'#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#si', array('locale', 'tld'), array(
|
||||
'#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#sDi', array('locale', 'tld'), array(
|
||||
array('variable', '.', '[^\.]++', 'tld'),
|
||||
array('text', '.example'),
|
||||
array('variable', '', '[^\.]++', 'locale'),
|
||||
|
|
@ -361,10 +361,10 @@ class RouteCompilerTest extends TestCase
|
|||
array(
|
||||
'Route with host variables that has a default value',
|
||||
array('/hello', array('locale' => 'a', 'tld' => 'b'), array(), array(), '{locale}.example.{tld}'),
|
||||
'/hello', '#^/hello$#s', array('locale', 'tld'), array(), array(
|
||||
'/hello', '#^/hello$#sD', array('locale', 'tld'), array(), array(
|
||||
array('text', '/hello'),
|
||||
),
|
||||
'#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#si', array('locale', 'tld'), array(
|
||||
'#^(?P<locale>[^\.]++)\.example\.(?P<tld>[^\.]++)$#sDi', array('locale', 'tld'), array(
|
||||
array('variable', '.', '[^\.]++', 'tld'),
|
||||
array('text', '.example'),
|
||||
array('variable', '', '[^\.]++', 'locale'),
|
||||
|
|
|
|||
20
pfosten/vendor/symfony/routing/Tests/RouteTest.php
vendored
Executable file → Normal file
20
pfosten/vendor/symfony/routing/Tests/RouteTest.php
vendored
Executable file → Normal file
|
|
@ -220,6 +220,24 @@ class RouteTest extends TestCase
|
|||
$this->assertNotSame($route, $unserialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that unserialization does not fail when the compiled Route is of a
|
||||
* class other than CompiledRoute, such as a subclass of it.
|
||||
*/
|
||||
public function testSerializeWhenCompiledWithClass()
|
||||
{
|
||||
$route = new Route('/', array(), array(), array('compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler'));
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route');
|
||||
|
||||
$serialized = serialize($route);
|
||||
try {
|
||||
$unserialized = unserialize($serialized);
|
||||
$this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully');
|
||||
} catch (\Exception $e) {
|
||||
$this->fail('unserializing a route which uses a custom compiled route class');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the serialized representation of a route in one symfony version
|
||||
* also works in later symfony versions, i.e. the unserialized route is in the
|
||||
|
|
@ -227,7 +245,7 @@ class RouteTest extends TestCase
|
|||
*/
|
||||
public function testSerializedRepresentationKeepsWorking()
|
||||
{
|
||||
$serialized = 'C:31:"Symfony\Component\Routing\Route":934:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":569:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:30:"#^/prefix(?:/(?P<foo>\d+))?$#s";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:39:"#^(?P<locale>[^\.]++)\.example\.net$#si";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}';
|
||||
$serialized = 'C:31:"Symfony\Component\Routing\Route":936:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":571:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:31:"#^/prefix(?:/(?P<foo>\d+))?$#sD";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:40:"#^(?P<locale>[^\.]++)\.example\.net$#sDi";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}';
|
||||
$unserialized = unserialize($serialized);
|
||||
|
||||
$route = new Route('/prefix/{foo}', array('foo' => 'default'), array('foo' => '\d+'));
|
||||
|
|
|
|||
9
pfosten/vendor/symfony/routing/Tests/RouterTest.php
vendored
Executable file → Normal file
9
pfosten/vendor/symfony/routing/Tests/RouterTest.php
vendored
Executable file → Normal file
|
|
@ -12,8 +12,9 @@
|
|||
namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Router;
|
||||
|
||||
class RouterTest extends TestCase
|
||||
{
|
||||
|
|
@ -83,7 +84,7 @@ class RouterTest extends TestCase
|
|||
{
|
||||
$this->router->setOption('resource_type', 'ResourceType');
|
||||
|
||||
$routeCollection = $this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock();
|
||||
$routeCollection = new RouteCollection();
|
||||
|
||||
$this->loader->expects($this->once())
|
||||
->method('load')->with('routing.yml', 'ResourceType')
|
||||
|
|
@ -101,7 +102,7 @@ class RouterTest extends TestCase
|
|||
|
||||
$this->loader->expects($this->once())
|
||||
->method('load')->with('routing.yml', null)
|
||||
->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock()));
|
||||
->will($this->returnValue(new RouteCollection()));
|
||||
|
||||
$this->assertInstanceOf('Symfony\\Component\\Routing\\Matcher\\UrlMatcher', $this->router->getMatcher());
|
||||
}
|
||||
|
|
@ -123,7 +124,7 @@ class RouterTest extends TestCase
|
|||
|
||||
$this->loader->expects($this->once())
|
||||
->method('load')->with('routing.yml', null)
|
||||
->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RouteCollection')->getMock()));
|
||||
->will($this->returnValue(new RouteCollection()));
|
||||
|
||||
$this->assertInstanceOf('Symfony\\Component\\Routing\\Generator\\UrlGenerator', $this->router->getGenerator());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue