Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
50
vendor/symfony/routing/Tests/Annotation/RouteTest.php
vendored
Normal file
50
vendor/symfony/routing/Tests/Annotation/RouteTest.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Annotation;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class RouteTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testInvalidRouteParameter()
|
||||
{
|
||||
$route = new Route(array('foo' => 'bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidParameters
|
||||
*/
|
||||
public function testRouteParameters($parameter, $value, $getter)
|
||||
{
|
||||
$route = new Route(array($parameter => $value));
|
||||
$this->assertEquals($route->$getter(), $value);
|
||||
}
|
||||
|
||||
public function getValidParameters()
|
||||
{
|
||||
return array(
|
||||
array('value', '/Blog', 'getPath'),
|
||||
array('requirements', array('locale' => 'en'), 'getRequirements'),
|
||||
array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
|
||||
array('name', 'blog_index', 'getName'),
|
||||
array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
|
||||
array('schemes', array('https'), 'getSchemes'),
|
||||
array('methods', array('GET', 'POST'), 'getMethods'),
|
||||
array('host', '{locale}.example.com', 'getHost'),
|
||||
array('condition', 'context.getMethod() == "GET"', 'getCondition'),
|
||||
);
|
||||
}
|
||||
}
|
27
vendor/symfony/routing/Tests/CompiledRouteTest.php
vendored
Normal file
27
vendor/symfony/routing/Tests/CompiledRouteTest.php
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\CompiledRoute;
|
||||
|
||||
class CompiledRouteTest extends TestCase
|
||||
{
|
||||
public function testAccessors()
|
||||
{
|
||||
$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');
|
||||
$this->assertEquals(array('variables'), $compiled->getVariables(), '__construct() takes an array of variables as its ninth argument');
|
||||
}
|
||||
}
|
36
vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Normal file
36
vendor/symfony/routing/Tests/DependencyInjection/RoutingResolverPassTest.php
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
|
||||
|
||||
class RoutingResolverPassTest extends TestCase
|
||||
{
|
||||
public function testProcess()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->register('routing.resolver', LoaderResolver::class);
|
||||
$container->register('loader1')->addTag('routing.loader');
|
||||
$container->register('loader2')->addTag('routing.loader');
|
||||
|
||||
(new RoutingResolverPass())->process($container);
|
||||
|
||||
$this->assertEquals(
|
||||
array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))),
|
||||
$container->getDefinition('routing.resolver')->getMethodCalls()
|
||||
);
|
||||
}
|
||||
}
|
16
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php
vendored
Normal file
16
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
abstract class AbstractClass
|
||||
{
|
||||
}
|
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php
vendored
Normal file
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BarClass.php
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
class BarClass
|
||||
{
|
||||
public function routeAction($arg1, $arg2 = 'defaultValue2', $arg3 = 'defaultValue3')
|
||||
{
|
||||
}
|
||||
}
|
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Normal file
19
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/BazClass.php
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
class BazClass
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
}
|
||||
}
|
16
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php
vendored
Normal file
16
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooClass.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
class FooClass
|
||||
{
|
||||
}
|
13
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php
vendored
Normal file
13
vendor/symfony/routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
||||
|
||||
trait FooTrait
|
||||
{
|
||||
public function doBar()
|
||||
{
|
||||
$baz = self::class;
|
||||
if (true) {
|
||||
}
|
||||
}
|
||||
}
|
18
vendor/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php
vendored
Normal file
18
vendor/symfony/routing/Tests/Fixtures/CustomCompiledRoute.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\CompiledRoute;
|
||||
|
||||
class CustomCompiledRoute extends CompiledRoute
|
||||
{
|
||||
}
|
26
vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php
vendored
Normal file
26
vendor/symfony/routing/Tests/Fixtures/CustomRouteCompiler.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCompiler;
|
||||
|
||||
class CustomRouteCompiler extends RouteCompiler
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function compile(Route $route)
|
||||
{
|
||||
return new CustomCompiledRoute('', '', array(), array());
|
||||
}
|
||||
}
|
26
vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php
vendored
Normal file
26
vendor/symfony/routing/Tests/Fixtures/CustomXmlFileLoader.php
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Config\Util\XmlUtils;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
|
||||
/**
|
||||
* XmlFileLoader with schema validation turned off.
|
||||
*/
|
||||
class CustomXmlFileLoader extends XmlFileLoader
|
||||
{
|
||||
protected function loadFile($file)
|
||||
{
|
||||
return XmlUtils::loadFile($file, function () { return true; });
|
||||
}
|
||||
}
|
24
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php
vendored
Normal file
24
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses;
|
||||
|
||||
trait AnonymousClassInTrait
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
return new class() {
|
||||
public function foo()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
3
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/NoStartTagClass.php
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
class NoStartTagClass
|
||||
{
|
||||
}
|
19
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php
vendored
Normal file
19
vendor/symfony/routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses;
|
||||
|
||||
class VariadicClass
|
||||
{
|
||||
public function routeAction(...$params)
|
||||
{
|
||||
}
|
||||
}
|
30
vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php
vendored
Normal file
30
vendor/symfony/routing/Tests/Fixtures/RedirectableUrlMatcher.php
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Fixtures;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface
|
||||
{
|
||||
public function redirect($path, $route, $scheme = null)
|
||||
{
|
||||
return array(
|
||||
'_controller' => 'Some controller reference...',
|
||||
'path' => $path,
|
||||
'scheme' => $scheme,
|
||||
);
|
||||
}
|
||||
}
|
0
vendor/symfony/routing/Tests/Fixtures/annotated.php
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/annotated.php
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/bad_format.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/bad_format.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
blog_show:
|
||||
path: /blog/{slug}
|
||||
defaults: { _controller: "MyBundle:Blog:show" }
|
0
vendor/symfony/routing/Tests/Fixtures/bar.xml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/bar.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml">
|
||||
<default key="_controller">FrameworkBundle:Template:template</default>
|
||||
</import>
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/controller/import__controller.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
_static:
|
||||
resource: routing.yml
|
||||
defaults:
|
||||
_controller: FrameworkBundle:Template:template
|
8
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template" />
|
||||
</routes>
|
3
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/controller/import_controller.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
_static:
|
||||
resource: routing.yml
|
||||
controller: FrameworkBundle:Template:template
|
10
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="routing.xml" controller="FrameworkBundle:Template:template">
|
||||
<default key="_controller">AppBundle:Blog:index</default>
|
||||
</import>
|
||||
</routes>
|
5
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml
vendored
Normal file
5
vendor/symfony/routing/Tests/Fixtures/controller/import_override_defaults.yml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
_static:
|
||||
resource: routing.yml
|
||||
controller: FrameworkBundle:Template:template
|
||||
defaults:
|
||||
_controller: AppBundle:Homepage:show
|
10
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="app_blog" path="/blog" controller="AppBundle:Homepage:show">
|
||||
<default key="_controller">AppBundle:Blog:index</default>
|
||||
</route>
|
||||
</routes>
|
5
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml
vendored
Normal file
5
vendor/symfony/routing/Tests/Fixtures/controller/override_defaults.yml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
app_blog:
|
||||
path: /blog
|
||||
controller: AppBundle:Homepage:show
|
||||
defaults:
|
||||
_controller: AppBundle:Blog:index
|
14
vendor/symfony/routing/Tests/Fixtures/controller/routing.xml
vendored
Normal file
14
vendor/symfony/routing/Tests/Fixtures/controller/routing.xml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="app_homepage" path="/" controller="AppBundle:Homepage:show" />
|
||||
|
||||
<route id="app_blog" path="/blog">
|
||||
<default key="_controller">AppBundle:Blog:list</default>
|
||||
</route>
|
||||
|
||||
<route id="app_logout" path="/logout" />
|
||||
</routes>
|
11
vendor/symfony/routing/Tests/Fixtures/controller/routing.yml
vendored
Normal file
11
vendor/symfony/routing/Tests/Fixtures/controller/routing.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
app_homepage:
|
||||
path: /
|
||||
controller: AppBundle:Homepage:show
|
||||
|
||||
app_blog:
|
||||
path: /blog
|
||||
defaults:
|
||||
_controller: AppBundle:Blog:list
|
||||
|
||||
app_logout:
|
||||
path: /logout
|
2
vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes1.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
route1:
|
||||
path: /route/1
|
2
vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/directory/recurse/routes2.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
route2:
|
||||
path: /route/2
|
2
vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/directory/routes3.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
route3:
|
||||
path: /route/3
|
3
vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/directory_import/import.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
_directory:
|
||||
resource: "../directory"
|
||||
type: directory
|
37
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php
vendored
Normal file
37
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher0.php
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
|
||||
}
|
||||
}
|
318
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php
vendored
Normal file
318
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher1.php
vendored
Normal file
|
@ -0,0 +1,318 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/foo')) {
|
||||
// foo
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ('/foofoo' === $pathinfo) {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
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 $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
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 $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/test')) {
|
||||
if (0 === strpos($pathinfo, '/test/baz')) {
|
||||
// baz
|
||||
if ('/test/baz' === $pathinfo) {
|
||||
return array('_route' => 'baz');
|
||||
}
|
||||
|
||||
// baz2
|
||||
if ('/test/baz.html' === $pathinfo) {
|
||||
return array('_route' => 'baz2');
|
||||
}
|
||||
|
||||
// baz3
|
||||
if ('/test/baz3/' === $pathinfo) {
|
||||
return array('_route' => 'baz3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// baz4
|
||||
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>[^/]++)/$#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 $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
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 $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
// space
|
||||
if ('/spa ce' === $pathinfo) {
|
||||
return array('_route' => 'space');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo1
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overridden
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
|
||||
}
|
||||
|
||||
// bar2
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
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/' === $pathinfo) {
|
||||
return array('_route' => 'hey');
|
||||
}
|
||||
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// foo3
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/aba')) {
|
||||
// ababa
|
||||
if ('/ababa' === $pathinfo) {
|
||||
return array('_route' => 'ababa');
|
||||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
}
|
||||
|
||||
// route2
|
||||
if ('/c2/route2' === $pathinfo) {
|
||||
return array('_route' => 'route2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route6
|
||||
if ('/route6' === $pathinfo) {
|
||||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ('/route11' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
|
||||
}
|
||||
|
||||
// route12
|
||||
if ('/route12' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route13
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route17
|
||||
if ('/route17' === $pathinfo) {
|
||||
return array('_route' => 'route17');
|
||||
}
|
||||
|
||||
// a
|
||||
if ('/a/a...' === $pathinfo) {
|
||||
return array('_route' => 'a');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
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>[^/]++)$#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();
|
||||
}
|
||||
}
|
380
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php
vendored
Normal file
380
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher2.php
vendored
Normal file
|
@ -0,0 +1,380 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/foo')) {
|
||||
// foo
|
||||
if (preg_match('#^/foo/(?P<bar>baz|symfony)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo')), array ( 'def' => 'test',));
|
||||
}
|
||||
|
||||
// foofoo
|
||||
if ('/foofoo' === $pathinfo) {
|
||||
return array ( 'def' => 'test', '_route' => 'foofoo',);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/bar')) {
|
||||
// bar
|
||||
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 $ret;
|
||||
}
|
||||
not_bar:
|
||||
|
||||
// barhead
|
||||
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 $ret;
|
||||
}
|
||||
not_barhead:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/test')) {
|
||||
if (0 === strpos($pathinfo, '/test/baz')) {
|
||||
// baz
|
||||
if ('/test/baz' === $pathinfo) {
|
||||
return array('_route' => 'baz');
|
||||
}
|
||||
|
||||
// baz2
|
||||
if ('/test/baz.html' === $pathinfo) {
|
||||
return array('_route' => 'baz2');
|
||||
}
|
||||
|
||||
// baz3
|
||||
if ('/test/baz3' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_baz3:
|
||||
|
||||
}
|
||||
|
||||
// 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 $ret;
|
||||
}
|
||||
not_baz4:
|
||||
|
||||
// baz5
|
||||
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 $ret;
|
||||
}
|
||||
not_baz5:
|
||||
|
||||
// baz.baz6
|
||||
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 $ret;
|
||||
}
|
||||
not_bazbaz6:
|
||||
|
||||
}
|
||||
|
||||
// quoter
|
||||
if (preg_match('#^/(?P<quoter>[\']+)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'quoter')), array ());
|
||||
}
|
||||
|
||||
// space
|
||||
if ('/spa ce' === $pathinfo) {
|
||||
return array('_route' => 'space');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
if (0 === strpos($pathinfo, '/a/b\'b')) {
|
||||
// foo1
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar1')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overridden
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo2')), array ());
|
||||
}
|
||||
|
||||
// bar2
|
||||
if (preg_match('#^/a/b\'b/(?P<bar1>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar2')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/multi')) {
|
||||
// helloWorld
|
||||
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) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_hey:
|
||||
|
||||
// overridden2
|
||||
if ('/multi/new' === $pathinfo) {
|
||||
return array('_route' => 'overridden2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// foo3
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'bar3')), array ());
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/aba')) {
|
||||
// ababa
|
||||
if ('/ababa' === $pathinfo) {
|
||||
return array('_route' => 'ababa');
|
||||
}
|
||||
|
||||
// foo4
|
||||
if (preg_match('#^/aba/(?P<foo>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'foo4')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$host = $context->getHost();
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route1
|
||||
if ('/route1' === $pathinfo) {
|
||||
return array('_route' => 'route1');
|
||||
}
|
||||
|
||||
// route2
|
||||
if ('/c2/route2' === $pathinfo) {
|
||||
return array('_route' => 'route2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^b\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route3
|
||||
if ('/c2/route3' === $pathinfo) {
|
||||
return array('_route' => 'route3');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^a\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route4
|
||||
if ('/route4' === $pathinfo) {
|
||||
return array('_route' => 'route4');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route5
|
||||
if ('/route5' === $pathinfo) {
|
||||
return array('_route' => 'route5');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// route6
|
||||
if ('/route6' === $pathinfo) {
|
||||
return array('_route' => 'route6');
|
||||
}
|
||||
|
||||
if (preg_match('#^(?P<var1>[^\\.]++)\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
if (0 === strpos($pathinfo, '/route1')) {
|
||||
// route11
|
||||
if ('/route11' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route11')), array ());
|
||||
}
|
||||
|
||||
// route12
|
||||
if ('/route12' === $pathinfo) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, array('_route' => 'route12')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route13
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($hostMatches, $matches, array('_route' => 'route14')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (preg_match('#^c\\.example\\.com$#sDi', $host, $hostMatches)) {
|
||||
// route15
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'route16')), array ( 'var1' => 'val',));
|
||||
}
|
||||
|
||||
// route17
|
||||
if ('/route17' === $pathinfo) {
|
||||
return array('_route' => 'route17');
|
||||
}
|
||||
|
||||
// a
|
||||
if ('/a/a...' === $pathinfo) {
|
||||
return array('_route' => 'a');
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a/b')) {
|
||||
// b
|
||||
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>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'c')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// secure
|
||||
if ('/secure' === $pathinfo) {
|
||||
$ret = array('_route' => 'secure');
|
||||
$requiredSchemes = array ( 'https' => 0,);
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_secure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'secure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_secure:
|
||||
|
||||
// nonsecure
|
||||
if ('/nonsecure' === $pathinfo) {
|
||||
$ret = array('_route' => 'nonsecure');
|
||||
$requiredSchemes = array ( 'http' => 0,);
|
||||
if (!isset($requiredSchemes[$context->getScheme()])) {
|
||||
if ('GET' !== $canonicalMethod) {
|
||||
goto not_nonsecure;
|
||||
}
|
||||
|
||||
return array_replace($ret, $this->redirect($rawPathinfo, 'nonsecure', key($requiredSchemes)));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
55
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php
vendored
Normal file
55
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher3.php
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/rootprefix')) {
|
||||
// static
|
||||
if ('/rootprefix/test' === $pathinfo) {
|
||||
return array('_route' => 'static');
|
||||
}
|
||||
|
||||
// dynamic
|
||||
if (preg_match('#^/rootprefix/(?P<var>[^/]++)$#sD', $pathinfo, $matches)) {
|
||||
return $this->mergeDefaults(array_replace($matches, array('_route' => 'dynamic')), array ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// with-condition
|
||||
if ('/with-condition' === $pathinfo && ($context->getMethod() == "GET")) {
|
||||
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();
|
||||
}
|
||||
}
|
112
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Normal file
112
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher4.php
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
// just_head
|
||||
if ('/just_head' === $pathinfo) {
|
||||
$ret = array('_route' => 'just_head');
|
||||
if (!in_array($requestMethod, array('HEAD'))) {
|
||||
$allow = array_merge($allow, array('HEAD'));
|
||||
goto not_just_head;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_just_head:
|
||||
|
||||
// head_and_get
|
||||
if ('/head_and_get' === $pathinfo) {
|
||||
$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 $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_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 $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 $ret;
|
||||
}
|
||||
not_put_and_post:
|
||||
|
||||
// put_and_get_and_head
|
||||
if ('/put_and_post' === $pathinfo) {
|
||||
$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 $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();
|
||||
}
|
||||
}
|
209
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Normal file
209
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher5.php
vendored
Normal file
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/a')) {
|
||||
// a_first
|
||||
if ('/a/11' === $pathinfo) {
|
||||
return array('_route' => 'a_first');
|
||||
}
|
||||
|
||||
// a_second
|
||||
if ('/a/22' === $pathinfo) {
|
||||
return array('_route' => 'a_second');
|
||||
}
|
||||
|
||||
// a_third
|
||||
if ('/a/333' === $pathinfo) {
|
||||
return array('_route' => 'a_third');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// a_wildcard
|
||||
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) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_a_fourth:
|
||||
|
||||
// a_fifth
|
||||
if ('/a/55' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_a_fifth:
|
||||
|
||||
// a_sixth
|
||||
if ('/a/66' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_a_sixth:
|
||||
|
||||
}
|
||||
|
||||
// nested_wildcard
|
||||
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) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_nested_a:
|
||||
|
||||
// nested_b
|
||||
if ('/nested/group/b' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_nested_b:
|
||||
|
||||
// nested_c
|
||||
if ('/nested/group/c' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_nested_c:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/slashed/group')) {
|
||||
// slashed_a
|
||||
if ('/slashed/group' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_slashed_a:
|
||||
|
||||
// slashed_b
|
||||
if ('/slashed/group/b' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_slashed_b:
|
||||
|
||||
// slashed_c
|
||||
if ('/slashed/group/c' === $trimmedPathinfo) {
|
||||
$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 $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();
|
||||
}
|
||||
}
|
213
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Normal file
213
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher6.php
vendored
Normal file
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods/' === $pathinfo) {
|
||||
return array('_route' => 'simple_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method/' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
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;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
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>[^/]++)/$#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>[^/]++)/$#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 $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>[^/]++)/$#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 $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>[^/]++)/$#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 $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
|
||||
// simple_not_trailing_slash_no_methods
|
||||
if ('/not-trailing/simple/no-methods' === $pathinfo) {
|
||||
return array('_route' => 'simple_not_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
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>[^/]++)$#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>[^/]++)$#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 $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>[^/]++)$#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 $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>[^/]++)$#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 $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();
|
||||
}
|
||||
}
|
249
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Normal file
249
vendor/symfony/routing/Tests/Fixtures/dumper/url_matcher7.php
vendored
Normal file
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
/**
|
||||
* This class has been auto-generated
|
||||
* by the Symfony Routing Component.
|
||||
*/
|
||||
class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher
|
||||
{
|
||||
public function __construct(RequestContext $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
public function match($rawPathinfo)
|
||||
{
|
||||
$allow = array();
|
||||
$pathinfo = rawurldecode($rawPathinfo);
|
||||
$trimmedPathinfo = rtrim($pathinfo, '/');
|
||||
$context = $this->context;
|
||||
$request = $this->request ?: $this->createRequest($pathinfo);
|
||||
$requestMethod = $canonicalMethod = $context->getMethod();
|
||||
|
||||
if ('HEAD' === $requestMethod) {
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if (0 === strpos($pathinfo, '/trailing/simple')) {
|
||||
// simple_trailing_slash_no_methods
|
||||
if ('/trailing/simple/no-methods' === $trimmedPathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_trailing_slash_no_methods:
|
||||
|
||||
// simple_trailing_slash_GET_method
|
||||
if ('/trailing/simple/get-method' === $trimmedPathinfo) {
|
||||
$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;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_GET_method:
|
||||
|
||||
// simple_trailing_slash_HEAD_method
|
||||
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;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
not_simple_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_trailing_slash_POST_method
|
||||
if ('/trailing/simple/post-method/' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
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>[^/]++)/?$#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 $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>[^/]++)/?$#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;
|
||||
}
|
||||
|
||||
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>[^/]++)/$#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 $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>[^/]++)/$#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 $ret;
|
||||
}
|
||||
not_regex_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
elseif (0 === strpos($pathinfo, '/not-trailing/simple')) {
|
||||
// simple_not_trailing_slash_no_methods
|
||||
if ('/not-trailing/simple/no-methods' === $pathinfo) {
|
||||
return array('_route' => 'simple_not_trailing_slash_no_methods');
|
||||
}
|
||||
|
||||
// simple_not_trailing_slash_GET_method
|
||||
if ('/not-trailing/simple/get-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_GET_method:
|
||||
|
||||
// simple_not_trailing_slash_HEAD_method
|
||||
if ('/not-trailing/simple/head-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_HEAD_method:
|
||||
|
||||
// simple_not_trailing_slash_POST_method
|
||||
if ('/not-trailing/simple/post-method' === $pathinfo) {
|
||||
$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 $ret;
|
||||
}
|
||||
not_simple_not_trailing_slash_POST_method:
|
||||
|
||||
}
|
||||
|
||||
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>[^/]++)$#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>[^/]++)$#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 $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>[^/]++)$#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 $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>[^/]++)$#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 $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
vendor/symfony/routing/Tests/Fixtures/empty.yml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/empty.yml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/file_resource.yml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/file_resource.yml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/foo.xml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/foo.xml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/foo1.xml
vendored
Normal file
0
vendor/symfony/routing/Tests/Fixtures/foo1.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/bar.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/bar.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="bar_route" path="/bar" controller="AppBundle:Bar:view" />
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/glob/bar.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/glob/bar.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
bar_route:
|
||||
path: /bar
|
||||
defaults:
|
||||
_controller: AppBundle:Bar:view
|
8
vendor/symfony/routing/Tests/Fixtures/glob/baz.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/baz.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="baz_route" path="/baz" controller="AppBundle:Baz:view" />
|
||||
</routes>
|
4
vendor/symfony/routing/Tests/Fixtures/glob/baz.yml
vendored
Normal file
4
vendor/symfony/routing/Tests/Fixtures/glob/baz.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
baz_route:
|
||||
path: /baz
|
||||
defaults:
|
||||
_controller: AppBundle:Baz:view
|
8
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="ba?.xml" />
|
||||
</routes>
|
2
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/glob/import_multiple.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
_static:
|
||||
resource: ba?.yml
|
8
vendor/symfony/routing/Tests/Fixtures/glob/import_single.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/glob/import_single.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="b?r.xml" />
|
||||
</routes>
|
2
vendor/symfony/routing/Tests/Fixtures/glob/import_single.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/glob/import_single.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
_static:
|
||||
resource: b?r.yml
|
7
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl.php
vendored
Normal file
7
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl.php
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
return $routes->import('php_dsl_ba?.php');
|
||||
};
|
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_bar.php
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_bar.php
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('bar_route', '/bar')
|
||||
->defaults(array('_controller' => 'AppBundle:Bar:view'));
|
||||
|
||||
return $collection;
|
||||
};
|
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_baz.php
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/glob/php_dsl_baz.php
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$collection = $routes->collection();
|
||||
|
||||
$collection->add('baz_route', '/baz')
|
||||
->defaults(array('_controller' => 'AppBundle:Baz:view'));
|
||||
|
||||
return $collection;
|
||||
};
|
2
vendor/symfony/routing/Tests/Fixtures/incomplete.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/incomplete.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
blog_show:
|
||||
defaults: { _controller: MyBlogBundle:Blog:show }
|
20
vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Normal file
20
vendor/symfony/routing/Tests/Fixtures/list_defaults.xml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_in_list_defaults.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<list>
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_in_map_defaults.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<list key="list">
|
||||
<bool>true</bool>
|
||||
<int>1</int>
|
||||
<float>3.5</float>
|
||||
<string>foo</string>
|
||||
</list>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/list_null_values.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="list">
|
||||
<list>
|
||||
<bool xsi:nil="true" />
|
||||
<int xsi:nil="true" />
|
||||
<float xsi:nil="1" />
|
||||
<string xsi:nil="true" />
|
||||
<list xsi:nil="true" />
|
||||
<map xsi:nil="true" />
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
20
vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Normal file
20
vendor/symfony/routing/Tests/Fixtures/map_defaults.xml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_in_list_defaults.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<list>
|
||||
<map>
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</list>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_in_map_defaults.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="values">
|
||||
<map>
|
||||
<map key="map">
|
||||
<bool key="public">true</bool>
|
||||
<int key="page">1</int>
|
||||
<float key="price">3.5</float>
|
||||
<string key="title">foo</string>
|
||||
</map>
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/map_null_values.xml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="map">
|
||||
<map>
|
||||
<bool key="boolean" xsi:nil="true" />
|
||||
<int key="integer" xsi:nil="true" />
|
||||
<float key="float" xsi:nil="true" />
|
||||
<string key="string" xsi:nil="1" />
|
||||
<list key="list" xsi:nil="true" />
|
||||
<map key="map" xsi:nil="true" />
|
||||
</map>
|
||||
</default>
|
||||
</route>
|
||||
</routes>
|
8
vendor/symfony/routing/Tests/Fixtures/missing_id.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/missing_id.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route path="/test"></route>
|
||||
</routes>
|
8
vendor/symfony/routing/Tests/Fixtures/missing_path.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/missing_path.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="myroute"></route>
|
||||
</routes>
|
16
vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml
vendored
Normal file
16
vendor/symfony/routing/Tests/Fixtures/namespaceprefix.xml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<r:routes xmlns:r="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<r:route id="blog_show" path="/blog/{slug}" host="{_locale}.example.com">
|
||||
<r:default key="_controller">MyBundle:Blog:show</r:default>
|
||||
<requirement xmlns="http://symfony.com/schema/routing" key="slug">\w+</requirement>
|
||||
<r2:requirement xmlns:r2="http://symfony.com/schema/routing" key="_locale">en|fr|de</r2:requirement>
|
||||
<r:option key="compiler_class">RouteCompiler</r:option>
|
||||
<r:default key="page">
|
||||
<r3:int xmlns:r3="http://symfony.com/schema/routing">1</r3:int>
|
||||
</r:default>
|
||||
</r:route>
|
||||
</r:routes>
|
3
vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/nonesense_resource_plus_path.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
blog_show:
|
||||
resource: validpattern.yml
|
||||
path: /test
|
3
vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/nonesense_type_without_resource.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
blog_show:
|
||||
path: /blog/{slug}
|
||||
type: custom
|
10
vendor/symfony/routing/Tests/Fixtures/nonvalid.xml
vendored
Normal file
10
vendor/symfony/routing/Tests/Fixtures/nonvalid.xml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
<!-- </route> -->
|
||||
</routes>
|
1
vendor/symfony/routing/Tests/Fixtures/nonvalid.yml
vendored
Normal file
1
vendor/symfony/routing/Tests/Fixtures/nonvalid.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
1
vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml
vendored
Normal file
1
vendor/symfony/routing/Tests/Fixtures/nonvalid2.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
route: string
|
3
vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/nonvalidkeys.yml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
someroute:
|
||||
resource: path/to/some.yml
|
||||
name_prefix: test_
|
8
vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/nonvalidnode.xml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<foo>bar</foo>
|
||||
</routes>
|
12
vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/nonvalidroute.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
<option key="compiler_class">RouteCompiler</option>
|
||||
<foo key="bar">baz</foo>
|
||||
</route>
|
||||
</routes>
|
12
vendor/symfony/routing/Tests/Fixtures/null_values.xml
vendored
Normal file
12
vendor/symfony/routing/Tests/Fixtures/null_values.xml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}">
|
||||
<default key="foo" xsi:nil="true" />
|
||||
<default key="bar" xsi:nil="1" />
|
||||
<default key="foobar" xsi:nil="false">foo</default>
|
||||
<default key="baz" xsi:nil="0">bar</default>
|
||||
</route>
|
||||
</routes>
|
22
vendor/symfony/routing/Tests/Fixtures/php_dsl.php
vendored
Normal file
22
vendor/symfony/routing/Tests/Fixtures/php_dsl.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$routes
|
||||
->collection()
|
||||
->add('foo', '/foo')
|
||||
->condition('abc')
|
||||
->options(array('utf8' => true))
|
||||
->add('buz', 'zub')
|
||||
->controller('foo:act');
|
||||
|
||||
$routes->import('php_dsl_sub.php')
|
||||
->prefix('/sub')
|
||||
->requirements(array('id' => '\d+'));
|
||||
|
||||
$routes->add('ouf', '/ouf')
|
||||
->schemes(array('https'))
|
||||
->methods(array('GET'))
|
||||
->defaults(array('id' => 0));
|
||||
};
|
14
vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php
vendored
Normal file
14
vendor/symfony/routing/Tests/Fixtures/php_dsl_sub.php
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
return function (RoutingConfigurator $routes) {
|
||||
$add = $routes->collection('c_')
|
||||
->prefix('pub');
|
||||
|
||||
$add('bar', '/bar');
|
||||
|
||||
$add->collection('pub_')
|
||||
->host('host')
|
||||
->add('buz', 'buz');
|
||||
};
|
33
vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Normal file
33
vendor/symfony/routing/Tests/Fixtures/scalar_defaults.xml
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing
|
||||
http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog" path="/blog">
|
||||
<default key="_controller">
|
||||
<string>AcmeBlogBundle:Blog:index</string>
|
||||
</default>
|
||||
<default key="slug" xsi:nil="true" />
|
||||
<default key="published">
|
||||
<bool>true</bool>
|
||||
</default>
|
||||
<default key="page">
|
||||
<int>1</int>
|
||||
</default>
|
||||
<default key="price">
|
||||
<float>3.5</float>
|
||||
</default>
|
||||
<default key="archived">
|
||||
<bool>false</bool>
|
||||
</default>
|
||||
<default key="free">
|
||||
<bool>1</bool>
|
||||
</default>
|
||||
<default key="locked">
|
||||
<bool>0</bool>
|
||||
</default>
|
||||
<default key="foo" xsi:nil="true" />
|
||||
<default key="bar" xsi:nil="1" />
|
||||
</route>
|
||||
</routes>
|
2
vendor/symfony/routing/Tests/Fixtures/special_route_name.yml
vendored
Normal file
2
vendor/symfony/routing/Tests/Fixtures/special_route_name.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"#$péß^a|":
|
||||
path: "true"
|
18
vendor/symfony/routing/Tests/Fixtures/validpattern.php
vendored
Normal file
18
vendor/symfony/routing/Tests/Fixtures/validpattern.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('blog_show', new Route(
|
||||
'/blog/{slug}',
|
||||
array('_controller' => 'MyBlogBundle:Blog:show'),
|
||||
array('locale' => '\w+'),
|
||||
array('compiler_class' => 'RouteCompiler'),
|
||||
'{locale}.example.com',
|
||||
array('https'),
|
||||
array('GET', 'POST', 'put', 'OpTiOnS'),
|
||||
'context.getMethod() == "GET"'
|
||||
));
|
||||
|
||||
return $collection;
|
15
vendor/symfony/routing/Tests/Fixtures/validpattern.xml
vendored
Normal file
15
vendor/symfony/routing/Tests/Fixtures/validpattern.xml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<route id="blog_show" path="/blog/{slug}" host="{locale}.example.com" methods="GET|POST put,OpTiOnS" schemes="hTTps">
|
||||
<default key="_controller">MyBundle:Blog:show</default>
|
||||
<requirement key="locale">\w+</requirement>
|
||||
<option key="compiler_class">RouteCompiler</option>
|
||||
<condition>context.getMethod() == "GET"</condition>
|
||||
</route>
|
||||
|
||||
<route id="blog_show_inherited" path="/blog/{slug}" />
|
||||
</routes>
|
13
vendor/symfony/routing/Tests/Fixtures/validpattern.yml
vendored
Normal file
13
vendor/symfony/routing/Tests/Fixtures/validpattern.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
blog_show:
|
||||
path: /blog/{slug}
|
||||
defaults: { _controller: "MyBundle:Blog:show" }
|
||||
host: "{locale}.example.com"
|
||||
requirements: { 'locale': '\w+' }
|
||||
methods: ['GET','POST','put','OpTiOnS']
|
||||
schemes: ['https']
|
||||
condition: 'context.getMethod() == "GET"'
|
||||
options:
|
||||
compiler_class: RouteCompiler
|
||||
|
||||
blog_show_inherited:
|
||||
path: /blog/{slug}
|
18
vendor/symfony/routing/Tests/Fixtures/validresource.php
vendored
Normal file
18
vendor/symfony/routing/Tests/Fixtures/validresource.php
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/** @var $loader \Symfony\Component\Routing\Loader\PhpFileLoader */
|
||||
/** @var \Symfony\Component\Routing\RouteCollection $collection */
|
||||
$collection = $loader->import('validpattern.php');
|
||||
$collection->addDefaults(array(
|
||||
'foo' => 123,
|
||||
));
|
||||
$collection->addRequirements(array(
|
||||
'foo' => '\d+',
|
||||
));
|
||||
$collection->addOptions(array(
|
||||
'foo' => 'bar',
|
||||
));
|
||||
$collection->setCondition('context.getMethod() == "POST"');
|
||||
$collection->addPrefix('/prefix');
|
||||
|
||||
return $collection;
|
13
vendor/symfony/routing/Tests/Fixtures/validresource.xml
vendored
Normal file
13
vendor/symfony/routing/Tests/Fixtures/validresource.xml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<import resource="validpattern.xml" prefix="/{foo}" host="">
|
||||
<default key="foo">123</default>
|
||||
<requirement key="foo">\d+</requirement>
|
||||
<option key="foo">bar</option>
|
||||
<condition>context.getMethod() == "POST"</condition>
|
||||
</import>
|
||||
</routes>
|
8
vendor/symfony/routing/Tests/Fixtures/validresource.yml
vendored
Normal file
8
vendor/symfony/routing/Tests/Fixtures/validresource.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
_blog:
|
||||
resource: validpattern.yml
|
||||
prefix: /{foo}
|
||||
defaults: { 'foo': '123' }
|
||||
requirements: { 'foo': '\d+' }
|
||||
options: { 'foo': 'bar' }
|
||||
host: ""
|
||||
condition: 'context.getMethod() == "POST"'
|
5
vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php
vendored
Normal file
5
vendor/symfony/routing/Tests/Fixtures/with_define_path_variable.php
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
$path = '/1/2/3';
|
||||
|
||||
return new \Symfony\Component\Routing\RouteCollection();
|
3
vendor/symfony/routing/Tests/Fixtures/withdoctype.xml
vendored
Normal file
3
vendor/symfony/routing/Tests/Fixtures/withdoctype.xml
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE foo>
|
||||
<foo></foo>
|
181
vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php
vendored
Normal file
181
vendor/symfony/routing/Tests/Generator/Dumper/PhpGeneratorDumperTest.php
vendored
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Generator\Dumper;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Generator\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
|
||||
{
|
||||
/**
|
||||
* @var RouteCollection
|
||||
*/
|
||||
private $routeCollection;
|
||||
|
||||
/**
|
||||
* @var PhpGeneratorDumper
|
||||
*/
|
||||
private $generatorDumper;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $testTmpFilepath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $largeTestTmpFilepath;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$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';
|
||||
@unlink($this->testTmpFilepath);
|
||||
@unlink($this->largeTestTmpFilepath);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
@unlink($this->testTmpFilepath);
|
||||
|
||||
$this->routeCollection = null;
|
||||
$this->generatorDumper = null;
|
||||
$this->testTmpFilepath = null;
|
||||
}
|
||||
|
||||
public function testDumpWithRoutes()
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
|
||||
$this->routeCollection->add('Test2', new Route('/testing2'));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \ProjectUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
|
||||
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
|
||||
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
|
||||
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
|
||||
}
|
||||
|
||||
public function testDumpWithTooManyRoutes()
|
||||
{
|
||||
if (\defined('HHVM_VERSION_ID')) {
|
||||
$this->markTestSkipped('HHVM consumes too much memory on this test.');
|
||||
}
|
||||
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}'));
|
||||
for ($i = 0; $i < 32769; ++$i) {
|
||||
$this->routeCollection->add('route_'.$i, new Route('/route_'.$i));
|
||||
}
|
||||
$this->routeCollection->add('Test2', new Route('/testing2'));
|
||||
|
||||
file_put_contents($this->largeTestTmpFilepath, $this->generatorDumper->dump(array(
|
||||
'class' => 'ProjectLargeUrlGenerator',
|
||||
)));
|
||||
$this->routeCollection = $this->generatorDumper = null;
|
||||
include $this->largeTestTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \ProjectLargeUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$absoluteUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrlWithParameter = $projectUrlGenerator->generate('Test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$relativeUrlWithoutParameter = $projectUrlGenerator->generate('Test2', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing/bar', $absoluteUrlWithParameter);
|
||||
$this->assertEquals('http://localhost/app.php/testing2', $absoluteUrlWithoutParameter);
|
||||
$this->assertEquals('/app.php/testing/bar', $relativeUrlWithParameter);
|
||||
$this->assertEquals('/app.php/testing2', $relativeUrlWithoutParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDumpWithoutRoutes()
|
||||
{
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'WithoutRoutesUrlGenerator')));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \WithoutRoutesUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$projectUrlGenerator->generate('Test', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
*/
|
||||
public function testGenerateNonExistingRoute()
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/test'));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'NonExistingRoutesUrlGenerator')));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \NonExistingRoutesUrlGenerator(new RequestContext());
|
||||
$url = $projectUrlGenerator->generate('NonExisting', array());
|
||||
}
|
||||
|
||||
public function testDumpForRouteWithDefaults()
|
||||
{
|
||||
$this->routeCollection->add('Test', new Route('/testing/{foo}', array('foo' => 'bar')));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'DefaultRoutesUrlGenerator')));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \DefaultRoutesUrlGenerator(new RequestContext());
|
||||
$url = $projectUrlGenerator->generate('Test', array());
|
||||
|
||||
$this->assertEquals('/testing', $url);
|
||||
}
|
||||
|
||||
public function testDumpWithSchemeRequirement()
|
||||
{
|
||||
$this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https')));
|
||||
|
||||
file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator')));
|
||||
include $this->testTmpFilepath;
|
||||
|
||||
$projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));
|
||||
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('ftp://localhost/app.php/testing', $absoluteUrl);
|
||||
$this->assertEquals('ftp://localhost/app.php/testing', $relativeUrl);
|
||||
|
||||
$projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
|
||||
|
||||
$absoluteUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
$relativeUrl = $projectUrlGenerator->generate('Test1', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('https://localhost/app.php/testing', $absoluteUrl);
|
||||
$this->assertEquals('/app.php/testing', $relativeUrl);
|
||||
}
|
||||
}
|
724
vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php
vendored
Normal file
724
vendor/symfony/routing/Tests/Generator/UrlGeneratorTest.php
vendored
Normal file
|
@ -0,0 +1,724 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Generator;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
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
|
||||
{
|
||||
public function testAbsoluteUrlWithPort80()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testAbsoluteSecureUrlWithPort443()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('https://localhost/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlWithNonStandardPort()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('httpPort' => 8080))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost:8080/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testAbsoluteSecureUrlWithNonStandardPort()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes, array('httpsPort' => 8080, 'scheme' => 'https'))->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('https://localhost:8080/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithoutParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing/bar', $url);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithNullParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing.{format}', array('format' => null)));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testRelativeUrlWithNullParameterButNotOptional()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', array('foo' => null)));
|
||||
// This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.
|
||||
// Generating path "/testing//bar" would be wrong as matching this route would fail.
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithOptionalZeroParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{page}'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('page' => 0), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing/0', $url);
|
||||
}
|
||||
|
||||
public function testNotPassedOptionalParameterInBetween()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}/{page}', array('slug' => 'index', 'page' => 0)));
|
||||
$this->assertSame('/app.php/index/1', $this->getGenerator($routes)->generate('test', array('page' => 1)));
|
||||
$this->assertSame('/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testRelativeUrlWithExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
|
||||
public function testAbsoluteUrlWithExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
|
||||
public function testUrlWithNullExtraParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('foo' => null), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
$this->assertEquals('http://localhost/app.php/testing', $url);
|
||||
}
|
||||
|
||||
public function testUrlWithExtraParametersFromGlobals()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('bar', 'bar');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array('foo' => 'bar'));
|
||||
|
||||
$this->assertEquals('/app.php/testing?foo=bar', $url);
|
||||
}
|
||||
|
||||
public function testUrlWithGlobalParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('foo', 'bar');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array());
|
||||
|
||||
$this->assertEquals('/app.php/testing/bar', $url);
|
||||
}
|
||||
|
||||
public function testGlobalParameterHasHigherPriorityThanDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{_locale}', array('_locale' => 'en')));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$context = new RequestContext('/app.php');
|
||||
$context->setParameter('_locale', 'de');
|
||||
$generator->setContext($context);
|
||||
$url = $generator->generate('test', array());
|
||||
|
||||
$this->assertSame('/app.php/de', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
*/
|
||||
public function testGenerateWithoutRoutes()
|
||||
{
|
||||
$routes = $this->getRoutes('foo', new Route('/testing/{foo}'));
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
|
||||
*/
|
||||
public function testGenerateForRouteWithoutMandatoryParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}'));
|
||||
$this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidOptionalParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '1|2')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => '0'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrict()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
|
||||
$logger->expects($this->once())
|
||||
->method('error');
|
||||
$generator = $this->getGenerator($routes, array(), $logger);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array('foo' => '1'), array('foo' => 'd+')));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(null);
|
||||
$this->assertSame('/app.php/testing/bar', $generator->generate('test', array('foo' => 'bar')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidMandatoryParameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => 'd+')));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'bar'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testGenerateForRouteWithInvalidUtf8Parameter()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing/{foo}', array(), array('foo' => '\pL+'), array('utf8' => true)));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'abc123'), UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testRequiredParamAndEmptyPassed()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{slug}', array(), array('slug' => '.+')));
|
||||
$this->getGenerator($routes)->generate('test', array('slug' => ''));
|
||||
}
|
||||
|
||||
public function testSchemeRequirementDoesNothingIfSameCurrentScheme()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http')));
|
||||
$this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https')));
|
||||
$this->assertEquals('/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test'));
|
||||
}
|
||||
|
||||
public function testSchemeRequirementForcesAbsoluteUrl()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('https')));
|
||||
$this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('http')));
|
||||
$this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test'));
|
||||
}
|
||||
|
||||
public function testSchemeRequirementCreatesUrlForFirstRequiredScheme()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array(), array(), '', array('Ftp', 'https')));
|
||||
$this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testPathWithTwoStartingSlashes()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('//path-and-not-domain'));
|
||||
|
||||
// this must not generate '//path-and-not-domain' because that would be a network path
|
||||
$this->assertSame('/path-and-not-domain', $this->getGenerator($routes, array('BaseUrl' => ''))->generate('test'));
|
||||
}
|
||||
|
||||
public function testNoTrailingSlashForMultipleOptionalParameters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/category/{slug1}/{slug2}/{slug3}', array('slug2' => null, 'slug3' => null)));
|
||||
|
||||
$this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', array('slug1' => 'foo')));
|
||||
}
|
||||
|
||||
public function testWithAnIntegerAsADefaultValue()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{default}', array('default' => 0)));
|
||||
|
||||
$this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', array('default' => 'foo')));
|
||||
}
|
||||
|
||||
public function testNullForOptionalParameterIsIgnored()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test/{default}', array('default' => 0)));
|
||||
|
||||
$this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => null)));
|
||||
}
|
||||
|
||||
public function testQueryParamSameAsDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test', array('page' => 1)));
|
||||
|
||||
$this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', array('page' => 2)));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => 1)));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => '1')));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testArrayQueryParamSameAsDefault()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/test', array('array' => array('foo', 'bar'))));
|
||||
|
||||
$this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', array('array' => array('bar', 'foo'))));
|
||||
$this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', array('array' => array('a' => 'foo', 'b' => 'bar'))));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array('foo', 'bar'))));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array(1 => 'bar', 0 => 'foo'))));
|
||||
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testGenerateWithSpecialRouteName()
|
||||
{
|
||||
$routes = $this->getRoutes('$péß^a|', new Route('/bar'));
|
||||
|
||||
$this->assertSame('/app.php/bar', $this->getGenerator($routes)->generate('$péß^a|'));
|
||||
}
|
||||
|
||||
public function testUrlEncoding()
|
||||
{
|
||||
$expectedPath = '/app.php/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'
|
||||
.'/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'
|
||||
.'?query=%40%3A%5B%5D/%28%29%2A%27%22%20%2B%2C%3B-._~%26%24%3C%3E%7C%7B%7D%25%5C%5E%60%21%3Ffoo%3Dbar%23id';
|
||||
|
||||
// This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986)
|
||||
// and other special ASCII chars. These chars are tested as static text path, variable path and query param.
|
||||
$chars = '@:[]/()*\'" +,;-._~&$<>|{}%\\^`!?foo=bar#id';
|
||||
$routes = $this->getRoutes('test', new Route("/$chars/{varpath}", array(), array('varpath' => '.+')));
|
||||
$this->assertSame($expectedPath, $this->getGenerator($routes)->generate('test', array(
|
||||
'varpath' => $chars,
|
||||
'query' => $chars,
|
||||
)));
|
||||
}
|
||||
|
||||
public function testEncodingOfRelativePathSegments()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/dir/../dir/..'));
|
||||
$this->assertSame('/app.php/dir/%2E%2E/dir/%2E%2E', $this->getGenerator($routes)->generate('test'));
|
||||
$routes = $this->getRoutes('test', new Route('/dir/./dir/.'));
|
||||
$this->assertSame('/app.php/dir/%2E/dir/%2E', $this->getGenerator($routes)->generate('test'));
|
||||
$routes = $this->getRoutes('test', new Route('/a./.a/a../..a/...'));
|
||||
$this->assertSame('/app.php/a./.a/a../..a/...', $this->getGenerator($routes)->generate('test'));
|
||||
}
|
||||
|
||||
public function testAdjacentVariables()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', array('z' => 'default-z', '_format' => 'html'), array('y' => '\d+')));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$this->assertSame('/app.php/foo123', $generator->generate('test', array('x' => 'foo', 'y' => '123')));
|
||||
$this->assertSame('/app.php/foo123bar.xml', $generator->generate('test', array('x' => 'foo', 'y' => '123', 'z' => 'bar', '_format' => 'xml')));
|
||||
|
||||
// The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything
|
||||
// and following optional variables like _format could never match.
|
||||
$this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('Symfony\Component\Routing\Exception\InvalidParameterException');
|
||||
$generator->generate('test', array('x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml'));
|
||||
}
|
||||
|
||||
public function testOptionalVariableWithNoRealSeparator()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/get{what}', array('what' => 'All')));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/get', $generator->generate('test'));
|
||||
$this->assertSame('/app.php/getSites', $generator->generate('test', array('what' => 'Sites')));
|
||||
}
|
||||
|
||||
public function testRequiredVariableWithNoRealSeparator()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/get{what}Suffix'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/getSitesSuffix', $generator->generate('test', array('what' => 'Sites')));
|
||||
}
|
||||
|
||||
public function testDefaultRequirementOfVariable()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
|
||||
$this->assertSame('/app.php/index.mobile.html', $generator->generate('test', array('page' => 'index', '_format' => 'mobile.html')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testDefaultRequirementOfVariableDisallowsSlash()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$this->getGenerator($routes)->generate('test', array('page' => 'index', '_format' => 'sl/ash'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testDefaultRequirementOfVariableDisallowsNextSeparator()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{page}.{_format}'));
|
||||
$this->getGenerator($routes)->generate('test', array('page' => 'do.t', '_format' => 'html'));
|
||||
}
|
||||
|
||||
public function testWithHostDifferentFromContext()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', array('name' => 'Fabien', 'locale' => 'fr')));
|
||||
}
|
||||
|
||||
public function testWithHostSameAsContext()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr')));
|
||||
}
|
||||
|
||||
public function testWithHostSameAsContextAndAbsolute()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/{name}', array(), array(), array(), '{locale}.example.com'));
|
||||
|
||||
$this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test', array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testUrlWithInvalidParameterInHost()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'bar'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Routing\Exception\InvalidParameterException
|
||||
*/
|
||||
public function testUrlWithInvalidParameterEqualsDefaultValueInHost()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array('foo' => 'baz'), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$this->getGenerator($routes)->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
}
|
||||
|
||||
public function testUrlWithInvalidParameterInHostInNonStrictMode()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('foo' => 'bar'), array(), '{foo}.example.com'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$generator->setStrictRequirements(false);
|
||||
$this->assertNull($generator->generate('test', array('foo' => 'baz'), UrlGeneratorInterface::ABSOLUTE_PATH));
|
||||
}
|
||||
|
||||
public function testHostIsCaseInsensitive()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/', array(), array('locale' => 'en|de|fr'), array(), '{locale}.FooBar.com'));
|
||||
$generator = $this->getGenerator($routes);
|
||||
$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')));
|
||||
|
||||
$this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'network path with different host'
|
||||
);
|
||||
$this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, array('host' => 'fr.example.com'))->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'), UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context'
|
||||
);
|
||||
$this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, array('scheme' => 'https'))->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context'
|
||||
);
|
||||
$this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',
|
||||
array('name' => 'Fabien', 'locale' => 'fr'), UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested'
|
||||
);
|
||||
}
|
||||
|
||||
public function testGenerateRelativePath()
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
$routes->add('article', new Route('/{author}/{article}/'));
|
||||
$routes->add('comments', new Route('/{author}/{article}/comments'));
|
||||
$routes->add('host', new Route('/{article}', array(), array(), array(), '{author}.example.com'));
|
||||
$routes->add('scheme', new Route('/{author}/blog', array(), array(), array(), '', array('https')));
|
||||
$routes->add('unrelated', new Route('/about'));
|
||||
|
||||
$generator = $this->getGenerator($routes, array('host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/'));
|
||||
|
||||
$this->assertSame('comments', $generator->generate('comments',
|
||||
array('author' => 'fabien', 'article' => 'symfony-is-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('comments?page=2', $generator->generate('comments',
|
||||
array('author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../twig-is-great/', $generator->generate('article',
|
||||
array('author' => 'fabien', 'article' => 'twig-is-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article',
|
||||
array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host',
|
||||
array('author' => 'bernhard', 'article' => 'forms-are-great'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme',
|
||||
array('author' => 'bernhard'), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
$this->assertSame('../../about', $generator->generate('unrelated',
|
||||
array(), UrlGeneratorInterface::RELATIVE_PATH)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideRelativePaths
|
||||
*/
|
||||
public function testGetRelativePath($sourcePath, $targetPath, $expectedPath)
|
||||
{
|
||||
$this->assertSame($expectedPath, UrlGenerator::getRelativePath($sourcePath, $targetPath));
|
||||
}
|
||||
|
||||
public function provideRelativePaths()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'/same/dir/',
|
||||
'/same/dir/',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'/same/file',
|
||||
'/same/file',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'/',
|
||||
'/file',
|
||||
'file',
|
||||
),
|
||||
array(
|
||||
'/',
|
||||
'/dir/file',
|
||||
'dir/file',
|
||||
),
|
||||
array(
|
||||
'/dir/file.html',
|
||||
'/dir/different-file.html',
|
||||
'different-file.html',
|
||||
),
|
||||
array(
|
||||
'/same/dir/extra-file',
|
||||
'/same/dir/',
|
||||
'./',
|
||||
),
|
||||
array(
|
||||
'/parent/dir/',
|
||||
'/parent/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
'/parent/dir/extra-file',
|
||||
'/parent/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
'/a/b/',
|
||||
'/x/y/z/',
|
||||
'../../x/y/z/',
|
||||
),
|
||||
array(
|
||||
'/a/b/c/d/e',
|
||||
'/a/c/d',
|
||||
'../../../c/d',
|
||||
),
|
||||
array(
|
||||
'/a/b/c//',
|
||||
'/a/b/c/',
|
||||
'../',
|
||||
),
|
||||
array(
|
||||
'/a/b/c/',
|
||||
'/a/b/c//',
|
||||
'.//',
|
||||
),
|
||||
array(
|
||||
'/root/a/b/c/',
|
||||
'/root/x/b/c/',
|
||||
'../../../x/b/c/',
|
||||
),
|
||||
array(
|
||||
'/a/b/c/d/',
|
||||
'/a',
|
||||
'../../../../a',
|
||||
),
|
||||
array(
|
||||
'/special-chars/sp%20ce/1€/mäh/e=mc²',
|
||||
'/special-chars/sp%20ce/1€/<µ>/e=mc²',
|
||||
'../<µ>/e=mc²',
|
||||
),
|
||||
array(
|
||||
'not-rooted',
|
||||
'dir/file',
|
||||
'dir/file',
|
||||
),
|
||||
array(
|
||||
'//dir/',
|
||||
'',
|
||||
'../../',
|
||||
),
|
||||
array(
|
||||
'/dir/',
|
||||
'/dir/file:with-colon',
|
||||
'./file:with-colon',
|
||||
),
|
||||
array(
|
||||
'/dir/',
|
||||
'/dir/subdir/file:with-colon',
|
||||
'subdir/file:with-colon',
|
||||
),
|
||||
array(
|
||||
'/dir/',
|
||||
'/dir/:subdir/',
|
||||
'./:subdir/',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFragmentsCanBeAppendedToUrls()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => 'frag ment'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$this->assertEquals('/app.php/testing#frag%20ment', $url);
|
||||
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => '0'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
$this->assertEquals('/app.php/testing#0', $url);
|
||||
}
|
||||
|
||||
public function testFragmentsDoNotEscapeValidCharacters()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing'));
|
||||
$url = $this->getGenerator($routes)->generate('test', array('_fragment' => '?/'), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing#?/', $url);
|
||||
}
|
||||
|
||||
public function testFragmentsCanBeDefinedAsDefaults()
|
||||
{
|
||||
$routes = $this->getRoutes('test', new Route('/testing', array('_fragment' => 'fragment')));
|
||||
$url = $this->getGenerator($routes)->generate('test', array(), UrlGeneratorInterface::ABSOLUTE_PATH);
|
||||
|
||||
$this->assertEquals('/app.php/testing#fragment', $url);
|
||||
}
|
||||
|
||||
protected function getGenerator(RouteCollection $routes, array $parameters = array(), $logger = null)
|
||||
{
|
||||
$context = new RequestContext('/app.php');
|
||||
foreach ($parameters as $key => $value) {
|
||||
$method = 'set'.$key;
|
||||
$context->$method($value);
|
||||
}
|
||||
|
||||
return new UrlGenerator($routes, $context, $logger);
|
||||
}
|
||||
|
||||
protected function getRoutes($name, Route $route)
|
||||
{
|
||||
$routes = new RouteCollection();
|
||||
$routes->add($name, $route);
|
||||
|
||||
return $routes;
|
||||
}
|
||||
}
|
33
vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php
vendored
Normal file
33
vendor/symfony/routing/Tests/Loader/AbstractAnnotationLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractAnnotationLoaderTest extends TestCase
|
||||
{
|
||||
public function getReader()
|
||||
{
|
||||
return $this->getMockBuilder('Doctrine\Common\Annotations\Reader')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
}
|
||||
|
||||
public function getClassLoader($reader)
|
||||
{
|
||||
return $this->getMockBuilder('Symfony\Component\Routing\Loader\AnnotationClassLoader')
|
||||
->setConstructorArgs(array($reader))
|
||||
->getMockForAbstractClass()
|
||||
;
|
||||
}
|
||||
}
|
296
vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php
vendored
Normal file
296
vendor/symfony/routing/Tests/Loader/AnnotationClassLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,296 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
protected $loader;
|
||||
private $reader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = $this->getClassLoader($this->reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLoadMissingClass()
|
||||
{
|
||||
$this->loader->load('MissingClass');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testLoadAbstractClass()
|
||||
{
|
||||
$this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\AbstractClass');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTestSupportsChecksResource
|
||||
*/
|
||||
public function testSupportsChecksResource($resource, $expectedSupports)
|
||||
{
|
||||
$this->assertSame($expectedSupports, $this->loader->supports($resource), '->supports() returns true if the resource is loadable');
|
||||
}
|
||||
|
||||
public function provideTestSupportsChecksResource()
|
||||
{
|
||||
return array(
|
||||
array('class', true),
|
||||
array('\fully\qualified\class\name', true),
|
||||
array('namespaced\class\without\leading\slash', true),
|
||||
array('ÿClassWithLegalSpecialCharacters', true),
|
||||
array('5', false),
|
||||
array('foo.foo', false),
|
||||
array(null, false),
|
||||
);
|
||||
}
|
||||
|
||||
public function testSupportsChecksTypeIfSpecified()
|
||||
{
|
||||
$this->assertTrue($this->loader->supports('class', 'annotation'), '->supports() checks the resource type if specified');
|
||||
$this->assertFalse($this->loader->supports('class', 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
|
||||
public function getLoadTests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
array('name' => 'route1', 'path' => '/path'),
|
||||
array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'),
|
||||
),
|
||||
array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
array('defaults' => array('arg2' => 'foo'), 'requirements' => array('arg3' => '\w+')),
|
||||
array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'),
|
||||
),
|
||||
array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
array('options' => array('foo' => 'bar')),
|
||||
array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'),
|
||||
),
|
||||
array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
array('schemes' => array('https'), 'methods' => array('GET')),
|
||||
array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'),
|
||||
),
|
||||
array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
array('condition' => 'context.getMethod() == "GET"'),
|
||||
array('arg2' => 'defaultValue2', 'arg3' => 'defaultValue3'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getLoadTests
|
||||
*/
|
||||
public function testLoad($className, $routeData = array(), $methodArgs = array())
|
||||
{
|
||||
$routeData = array_replace(array(
|
||||
'name' => 'route',
|
||||
'path' => '/',
|
||||
'requirements' => array(),
|
||||
'options' => array(),
|
||||
'defaults' => array(),
|
||||
'schemes' => array(),
|
||||
'methods' => array(),
|
||||
'condition' => '',
|
||||
), $routeData);
|
||||
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($routeData))))
|
||||
;
|
||||
|
||||
$routeCollection = $this->loader->load($className);
|
||||
$route = $routeCollection->get($routeData['name']);
|
||||
|
||||
$this->assertSame($routeData['path'], $route->getPath(), '->load preserves path annotation');
|
||||
$this->assertCount(
|
||||
\count($routeData['requirements']),
|
||||
array_intersect_assoc($routeData['requirements'], $route->getRequirements()),
|
||||
'->load preserves requirements annotation'
|
||||
);
|
||||
$this->assertCount(
|
||||
\count($routeData['options']),
|
||||
array_intersect_assoc($routeData['options'], $route->getOptions()),
|
||||
'->load preserves options annotation'
|
||||
);
|
||||
$this->assertCount(
|
||||
\count($routeData['defaults']),
|
||||
$route->getDefaults(),
|
||||
'->load preserves defaults annotation'
|
||||
);
|
||||
$this->assertEquals($routeData['schemes'], $route->getSchemes(), '->load preserves schemes annotation');
|
||||
$this->assertEquals($routeData['methods'], $route->getMethods(), '->load preserves methods annotation');
|
||||
$this->assertSame($routeData['condition'], $route->getCondition(), '->load preserves condition annotation');
|
||||
}
|
||||
|
||||
public function testClassRouteLoad()
|
||||
{
|
||||
$classRouteData = array(
|
||||
'name' => 'prefix_',
|
||||
'path' => '/prefix',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
|
||||
$methodRouteData = array(
|
||||
'name' => 'route1',
|
||||
'path' => '/path',
|
||||
'schemes' => array('http'),
|
||||
'methods' => array('POST', 'PUT'),
|
||||
);
|
||||
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getClassAnnotation')
|
||||
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
|
||||
;
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($methodRouteData))))
|
||||
;
|
||||
|
||||
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass');
|
||||
$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');
|
||||
$this->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route->getMethods(), '->load merges class and method route methods');
|
||||
}
|
||||
|
||||
public function testInvokableClassRouteLoad()
|
||||
{
|
||||
$classRouteData = array(
|
||||
'name' => 'route1',
|
||||
'path' => '/',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
|
||||
$this->reader
|
||||
->expects($this->exactly(1))
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($classRouteData))))
|
||||
;
|
||||
$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($classRouteData['name']);
|
||||
|
||||
$this->assertSame($classRouteData['path'], $route->getPath(), '->load preserves class route path');
|
||||
$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()
|
||||
{
|
||||
$classRouteData = array(
|
||||
'name' => 'route1',
|
||||
'path' => '/prefix',
|
||||
'schemes' => array('https'),
|
||||
'methods' => array('GET'),
|
||||
);
|
||||
|
||||
$methodRouteData = array(
|
||||
'name' => 'route2',
|
||||
'path' => '/path',
|
||||
'schemes' => array('http'),
|
||||
'methods' => array('POST', 'PUT'),
|
||||
);
|
||||
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getClassAnnotation')
|
||||
->will($this->returnValue($this->getAnnotatedRoute($classRouteData)))
|
||||
;
|
||||
$this->reader
|
||||
->expects($this->once())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($this->getAnnotatedRoute($methodRouteData))))
|
||||
;
|
||||
|
||||
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass');
|
||||
$route = $routeCollection->get($classRouteData['name']);
|
||||
|
||||
$this->assertNull($route, '->load ignores class route');
|
||||
|
||||
$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');
|
||||
$this->assertEquals(array_merge($classRouteData['methods'], $methodRouteData['methods']), $route->getMethods(), '->load merges class and method route methods');
|
||||
}
|
||||
|
||||
private function getAnnotatedRoute($data)
|
||||
{
|
||||
return new Route($data);
|
||||
}
|
||||
}
|
109
vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
vendored
Normal file
109
vendor/symfony/routing/Tests/Loader/AnnotationDirectoryLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
|
||||
|
||||
class AnnotationDirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
protected $loader;
|
||||
protected $reader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = new AnnotationDirectoryLoader(new FileLocator(), $this->getClassLoader($this->reader));
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$this->reader->expects($this->exactly(3))->method('getClassAnnotation');
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
}
|
||||
|
||||
public function testLoadIgnoresHiddenDirectories()
|
||||
{
|
||||
$this->expectAnnotationsToBeReadFrom(array(
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BazClass',
|
||||
'Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\FooClass',
|
||||
));
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->reader
|
||||
->expects($this->any())
|
||||
->method('getClassAnnotations')
|
||||
->will($this->returnValue(array()))
|
||||
;
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses');
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$fixturesDir = __DIR__.'/../Fixtures';
|
||||
|
||||
$this->assertTrue($this->loader->supports($fixturesDir), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$this->assertTrue($this->loader->supports($fixturesDir, 'annotation'), '->supports() checks the resource type if specified');
|
||||
$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)))
|
||||
->method('getClassAnnotation')
|
||||
->with($this->callback(function (\ReflectionClass $class) use ($classes) {
|
||||
return \in_array($class->getName(), $classes);
|
||||
}));
|
||||
}
|
||||
}
|
91
vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php
vendored
Normal file
91
vendor/symfony/routing/Tests/Loader/AnnotationFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
|
||||
|
||||
class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
protected $loader;
|
||||
protected $reader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$this->reader->expects($this->once())->method('getClassAnnotation');
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function testLoadTraitWithClassConstant()
|
||||
{
|
||||
$this->reader->expects($this->never())->method('getClassAnnotation');
|
||||
|
||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Did you forgot to add the "<?php" start tag at the beginning of the file?
|
||||
*/
|
||||
public function testLoadFileWithoutStartTag()
|
||||
{
|
||||
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/NoStartTagClass.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.6
|
||||
*/
|
||||
public function testLoadVariadic()
|
||||
{
|
||||
$route = new Route(array('path' => '/path/to/{id}'));
|
||||
$this->reader->expects($this->once())->method('getClassAnnotation');
|
||||
$this->reader->expects($this->once())->method('getMethodAnnotations')
|
||||
->will($this->returnValue(array($route)));
|
||||
|
||||
$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';
|
||||
|
||||
$this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified');
|
||||
$this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
}
|
49
vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php
vendored
Normal file
49
vendor/symfony/routing/Tests/Loader/ClosureLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Loader\ClosureLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class ClosureLoaderTest extends TestCase
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new ClosureLoader();
|
||||
|
||||
$closure = function () {};
|
||||
|
||||
$this->assertTrue($loader->supports($closure), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$this->assertTrue($loader->supports($closure, 'closure'), '->supports() checks the resource type if specified');
|
||||
$this->assertFalse($loader->supports($closure, 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
|
||||
public function testLoad()
|
||||
{
|
||||
$loader = new ClosureLoader();
|
||||
|
||||
$route = new Route('/');
|
||||
$routes = $loader->load(function () use ($route) {
|
||||
$routes = new RouteCollection();
|
||||
|
||||
$routes->add('foo', $route);
|
||||
|
||||
return $routes;
|
||||
});
|
||||
|
||||
$this->assertEquals($route, $routes->get('foo'), '->load() loads a \Closure resource');
|
||||
}
|
||||
}
|
74
vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php
vendored
Normal file
74
vendor/symfony/routing/Tests/Loader/DirectoryLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\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\RouteCollection;
|
||||
|
||||
class DirectoryLoaderTest extends AbstractAnnotationLoaderTest
|
||||
{
|
||||
private $loader;
|
||||
private $reader;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$locator = new FileLocator();
|
||||
$this->reader = $this->getReader();
|
||||
$this->loader = new DirectoryLoader($locator);
|
||||
$resolver = new LoaderResolver(array(
|
||||
new YamlFileLoader($locator),
|
||||
new AnnotationFileLoader($locator, $this->getClassLoader($this->reader)),
|
||||
$this->loader,
|
||||
));
|
||||
$this->loader->setResolver($resolver);
|
||||
}
|
||||
|
||||
public function testLoadDirectory()
|
||||
{
|
||||
$collection = $this->loader->load(__DIR__.'/../Fixtures/directory', 'directory');
|
||||
$this->verifyCollection($collection);
|
||||
}
|
||||
|
||||
public function testImportDirectory()
|
||||
{
|
||||
$collection = $this->loader->load(__DIR__.'/../Fixtures/directory_import', 'directory');
|
||||
$this->verifyCollection($collection);
|
||||
}
|
||||
|
||||
private function verifyCollection(RouteCollection $collection)
|
||||
{
|
||||
$routes = $collection->all();
|
||||
|
||||
$this->assertCount(3, $routes, 'Three routes are loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
|
||||
for ($i = 1; $i <= 3; ++$i) {
|
||||
$this->assertSame('/route/'.$i, $routes['route'.$i]->getPath());
|
||||
}
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$fixturesDir = __DIR__.'/../Fixtures';
|
||||
|
||||
$this->assertFalse($this->loader->supports($fixturesDir), '->supports(*) returns false');
|
||||
|
||||
$this->assertTrue($this->loader->supports($fixturesDir, 'directory'), '->supports(*, "directory") returns true');
|
||||
$this->assertFalse($this->loader->supports($fixturesDir, 'foo'), '->supports(*, "foo") returns false');
|
||||
}
|
||||
}
|
45
vendor/symfony/routing/Tests/Loader/GlobFileLoaderTest.php
vendored
Normal file
45
vendor/symfony/routing/Tests/Loader/GlobFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Resource\GlobResource;
|
||||
use Symfony\Component\Routing\Loader\GlobFileLoader;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class GlobFileLoaderTest extends TestCase
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new GlobFileLoader(new FileLocator());
|
||||
|
||||
$this->assertTrue($loader->supports('any-path', 'glob'), '->supports() returns true if the resource has the glob type');
|
||||
$this->assertFalse($loader->supports('any-path'), '->supports() returns false if the resource is not of glob type');
|
||||
}
|
||||
|
||||
public function testLoadAddsTheGlobResourceToTheContainer()
|
||||
{
|
||||
$loader = new GlobFileLoaderWithoutImport(new FileLocator());
|
||||
$collection = $loader->load(__DIR__.'/../Fixtures/directory/*.yml');
|
||||
|
||||
$this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/directory', '/*.yml', false), $collection->getResources()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
class GlobFileLoaderWithoutImport extends GlobFileLoader
|
||||
{
|
||||
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
|
||||
{
|
||||
return new RouteCollection();
|
||||
}
|
||||
}
|
123
vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php
vendored
Normal file
123
vendor/symfony/routing/Tests/Loader/ObjectRouteLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Routing\Loader\ObjectRouteLoader;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class ObjectRouteLoaderTest extends TestCase
|
||||
{
|
||||
public function testLoadCallsServiceAndReturnsCollection()
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
|
||||
// create a basic collection that will be returned
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo'));
|
||||
|
||||
$loader->loaderMap = array(
|
||||
'my_route_provider_service' => new RouteService($collection),
|
||||
);
|
||||
|
||||
$actualRoutes = $loader->load(
|
||||
'my_route_provider_service:loadRoutes',
|
||||
'service'
|
||||
);
|
||||
|
||||
$this->assertSame($collection, $actualRoutes);
|
||||
// the service file should be listed as a resource
|
||||
$this->assertNotEmpty($actualRoutes->getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @dataProvider getBadResourceStrings
|
||||
*/
|
||||
public function testExceptionWithoutSyntax($resourceString)
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->load($resourceString);
|
||||
}
|
||||
|
||||
public function getBadResourceStrings()
|
||||
{
|
||||
return array(
|
||||
array('Foo'),
|
||||
array('Bar::baz'),
|
||||
array('Foo:Bar:baz'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testExceptionOnNoObjectReturned()
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => 'NOT_AN_OBJECT');
|
||||
$loader->load('my_service:method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \BadMethodCallException
|
||||
*/
|
||||
public function testExceptionOnBadMethod()
|
||||
{
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => new \stdClass());
|
||||
$loader->load('my_service:method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testExceptionOnMethodNotReturningCollection()
|
||||
{
|
||||
$service = $this->getMockBuilder('stdClass')
|
||||
->setMethods(array('loadRoutes'))
|
||||
->getMock();
|
||||
$service->expects($this->once())
|
||||
->method('loadRoutes')
|
||||
->will($this->returnValue('NOT_A_COLLECTION'));
|
||||
|
||||
$loader = new ObjectRouteLoaderForTest();
|
||||
$loader->loaderMap = array('my_service' => $service);
|
||||
$loader->load('my_service:loadRoutes');
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectRouteLoaderForTest extends ObjectRouteLoader
|
||||
{
|
||||
public $loaderMap = array();
|
||||
|
||||
protected function getServiceObject($id)
|
||||
{
|
||||
return isset($this->loaderMap[$id]) ? $this->loaderMap[$id] : null;
|
||||
}
|
||||
}
|
||||
|
||||
class RouteService
|
||||
{
|
||||
private $collection;
|
||||
|
||||
public function __construct($collection)
|
||||
{
|
||||
$this->collection = $collection;
|
||||
}
|
||||
|
||||
public function loadRoutes()
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
}
|
133
vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php
vendored
Normal file
133
vendor/symfony/routing/Tests/Loader/PhpFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\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
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new PhpFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
|
||||
|
||||
$this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified');
|
||||
$this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
|
||||
public function testLoadWithRoute()
|
||||
{
|
||||
$loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('validpattern.php');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
$this->assertCount(1, $routes, 'One route is loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
$this->assertSame('/blog/{slug}', $route->getPath());
|
||||
$this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('{locale}.example.com', $route->getHost());
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
}
|
||||
}
|
||||
|
||||
public function testLoadWithImport()
|
||||
{
|
||||
$loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('validresource.php');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
$this->assertCount(1, $routes, 'One route is loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
$this->assertSame('/prefix/blog/{slug}', $route->getPath());
|
||||
$this->assertSame('MyBlogBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('{locale}.example.com', $route->getHost());
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
}
|
||||
}
|
||||
|
||||
public function testThatDefiningVariableInConfigFileHasNoSideEffects()
|
||||
{
|
||||
$locator = new FileLocator(array(__DIR__.'/../Fixtures'));
|
||||
$loader = new PhpFileLoader($locator);
|
||||
$routeCollection = $loader->load('with_define_path_variable.php');
|
||||
$resources = $routeCollection->getResources();
|
||||
$this->assertCount(1, $resources);
|
||||
$this->assertContainsOnly('Symfony\Component\Config\Resource\ResourceInterface', $resources);
|
||||
$fileResource = reset($resources);
|
||||
$this->assertSame(
|
||||
realpath($locator->locate('with_define_path_variable.php')),
|
||||
(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'));
|
||||
}
|
||||
}
|
385
vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php
vendored
Normal file
385
vendor/symfony/routing/Tests/Loader/XmlFileLoaderTest.php
vendored
Normal file
|
@ -0,0 +1,385 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Loader;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\XmlFileLoader;
|
||||
use Symfony\Component\Routing\Tests\Fixtures\CustomXmlFileLoader;
|
||||
|
||||
class XmlFileLoaderTest extends TestCase
|
||||
{
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new XmlFileLoader($this->getMockBuilder('Symfony\Component\Config\FileLocator')->getMock());
|
||||
|
||||
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
|
||||
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
|
||||
|
||||
$this->assertTrue($loader->supports('foo.xml', 'xml'), '->supports() checks the resource type if specified');
|
||||
$this->assertFalse($loader->supports('foo.xml', 'foo'), '->supports() checks the resource type if specified');
|
||||
}
|
||||
|
||||
public function testLoadWithRoute()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('validpattern.xml');
|
||||
$route = $routeCollection->get('blog_show');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\Routing\Route', $route);
|
||||
$this->assertSame('/blog/{slug}', $route->getPath());
|
||||
$this->assertSame('{locale}.example.com', $route->getHost());
|
||||
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('\w+', $route->getRequirement('locale'));
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertEquals(array('GET', 'POST', 'PUT', 'OPTIONS'), $route->getMethods());
|
||||
$this->assertEquals(array('https'), $route->getSchemes());
|
||||
$this->assertEquals('context.getMethod() == "GET"', $route->getCondition());
|
||||
}
|
||||
|
||||
public function testLoadWithNamespacePrefix()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('namespaceprefix.xml');
|
||||
|
||||
$this->assertCount(1, $routeCollection->all(), 'One route is loaded');
|
||||
|
||||
$route = $routeCollection->get('blog_show');
|
||||
$this->assertSame('/blog/{slug}', $route->getPath());
|
||||
$this->assertSame('{_locale}.example.com', $route->getHost());
|
||||
$this->assertSame('MyBundle:Blog:show', $route->getDefault('_controller'));
|
||||
$this->assertSame('\w+', $route->getRequirement('slug'));
|
||||
$this->assertSame('en|fr|de', $route->getRequirement('_locale'));
|
||||
$this->assertNull($route->getDefault('slug'));
|
||||
$this->assertSame('RouteCompiler', $route->getOption('compiler_class'));
|
||||
$this->assertSame(1, $route->getDefault('page'));
|
||||
}
|
||||
|
||||
public function testLoadWithImport()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('validresource.xml');
|
||||
$routes = $routeCollection->all();
|
||||
|
||||
$this->assertCount(2, $routes, 'Two routes are loaded');
|
||||
$this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
$this->assertSame('/{foo}/blog/{slug}', $route->getPath());
|
||||
$this->assertSame('123', $route->getDefault('foo'));
|
||||
$this->assertSame('\d+', $route->getRequirement('foo'));
|
||||
$this->assertSame('bar', $route->getOption('foo'));
|
||||
$this->assertSame('', $route->getHost());
|
||||
$this->assertSame('context.getMethod() == "POST"', $route->getCondition());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @dataProvider getPathsToInvalidFiles
|
||||
*/
|
||||
public function testLoadThrowsExceptionWithInvalidFile($filePath)
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader->load($filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @dataProvider getPathsToInvalidFiles
|
||||
*/
|
||||
public function testLoadThrowsExceptionWithInvalidFileEvenWithoutSchemaValidation($filePath)
|
||||
{
|
||||
$loader = new CustomXmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader->load($filePath);
|
||||
}
|
||||
|
||||
public function getPathsToInvalidFiles()
|
||||
{
|
||||
return array(array('nonvalidnode.xml'), array('nonvalidroute.xml'), array('nonvalid.xml'), array('missing_id.xml'), array('missing_path.xml'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Document types are not allowed.
|
||||
*/
|
||||
public function testDocTypeIsNotAllowed()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$loader->load('withdoctype.xml');
|
||||
}
|
||||
|
||||
public function testNullValues()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('null_values.xml');
|
||||
$route = $routeCollection->get('blog_show');
|
||||
|
||||
$this->assertTrue($route->hasDefault('foo'));
|
||||
$this->assertNull($route->getDefault('foo'));
|
||||
$this->assertTrue($route->hasDefault('bar'));
|
||||
$this->assertNull($route->getDefault('bar'));
|
||||
$this->assertEquals('foo', $route->getDefault('foobar'));
|
||||
$this->assertEquals('bar', $route->getDefault('baz'));
|
||||
}
|
||||
|
||||
public function testScalarDataTypeDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('scalar_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'slug' => null,
|
||||
'published' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'archived' => false,
|
||||
'free' => true,
|
||||
'locked' => false,
|
||||
'foo' => null,
|
||||
'bar' => null,
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(true, 1, 3.5, 'foo'),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListInListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('list_in_list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(array(true, 1, 3.5, 'foo')),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testListInMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('list_in_map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array('list' => array(true, 1, 3.5, 'foo')),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapInListDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('map_in_list_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array(array(
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
)),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testMapInMapDefaults()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('map_in_map_defaults.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'_controller' => 'AcmeBlogBundle:Blog:index',
|
||||
'values' => array('map' => array(
|
||||
'public' => true,
|
||||
'page' => 1,
|
||||
'price' => 3.5,
|
||||
'title' => 'foo',
|
||||
)),
|
||||
),
|
||||
$route->getDefaults()
|
||||
);
|
||||
}
|
||||
|
||||
public function testNullValuesInList()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('list_null_values.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(array(null, null, null, null, null, null), $route->getDefault('list'));
|
||||
}
|
||||
|
||||
public function testNullValuesInMap()
|
||||
{
|
||||
$loader = new XmlFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
|
||||
$routeCollection = $loader->load('map_null_values.xml');
|
||||
$route = $routeCollection->get('blog');
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'boolean' => null,
|
||||
'integer' => null,
|
||||
'float' => null,
|
||||
'string' => null,
|
||||
'list' => null,
|
||||
'map' => null,
|
||||
),
|
||||
$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'));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue