Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\DumperCollection;
|
||||
|
||||
class DumperCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetRoot()
|
||||
{
|
||||
$a = new DumperCollection();
|
||||
|
||||
$b = new DumperCollection();
|
||||
$a->add($b);
|
||||
|
||||
$c = new DumperCollection();
|
||||
$b->add($c);
|
||||
|
||||
$d = new DumperCollection();
|
||||
$c->add($d);
|
||||
|
||||
$this->assertSame($a, $c->getRoot());
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\DumperPrefixCollection;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\DumperRoute;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\DumperCollection;
|
||||
|
||||
class DumperPrefixCollectionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAddPrefixRoute()
|
||||
{
|
||||
$coll = new DumperPrefixCollection();
|
||||
$coll->setPrefix('');
|
||||
|
||||
$route = new DumperRoute('bar', new Route('/foo/bar'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('bar2', new Route('/foo/bar'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('qux', new Route('/foo/qux'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('bar3', new Route('/foo/bar'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('bar4', new Route(''));
|
||||
$result = $coll->addPrefixRoute($route);
|
||||
|
||||
$expect = <<<'EOF'
|
||||
|-coll /
|
||||
| |-coll /f
|
||||
| | |-coll /fo
|
||||
| | | |-coll /foo
|
||||
| | | | |-coll /foo/
|
||||
| | | | | |-coll /foo/b
|
||||
| | | | | | |-coll /foo/ba
|
||||
| | | | | | | |-coll /foo/bar
|
||||
| | | | | | | | |-route bar /foo/bar
|
||||
| | | | | | | | |-route bar2 /foo/bar
|
||||
| | | | | |-coll /foo/q
|
||||
| | | | | | |-coll /foo/qu
|
||||
| | | | | | | |-coll /foo/qux
|
||||
| | | | | | | | |-route qux /foo/qux
|
||||
| | | | | |-coll /foo/b
|
||||
| | | | | | |-coll /foo/ba
|
||||
| | | | | | | |-coll /foo/bar
|
||||
| | | | | | | | |-route bar3 /foo/bar
|
||||
| |-route bar4 /
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertSame($expect, $this->collectionToString($result->getRoot(), ' '));
|
||||
}
|
||||
|
||||
public function testMergeSlashNodes()
|
||||
{
|
||||
$coll = new DumperPrefixCollection();
|
||||
$coll->setPrefix('');
|
||||
|
||||
$route = new DumperRoute('bar', new Route('/foo/bar'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('bar2', new Route('/foo/bar'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('qux', new Route('/foo/qux'));
|
||||
$coll = $coll->addPrefixRoute($route);
|
||||
|
||||
$route = new DumperRoute('bar3', new Route('/foo/bar'));
|
||||
$result = $coll->addPrefixRoute($route);
|
||||
|
||||
$result->getRoot()->mergeSlashNodes();
|
||||
|
||||
$expect = <<<'EOF'
|
||||
|-coll /f
|
||||
| |-coll /fo
|
||||
| | |-coll /foo
|
||||
| | | |-coll /foo/b
|
||||
| | | | |-coll /foo/ba
|
||||
| | | | | |-coll /foo/bar
|
||||
| | | | | | |-route bar /foo/bar
|
||||
| | | | | | |-route bar2 /foo/bar
|
||||
| | | |-coll /foo/q
|
||||
| | | | |-coll /foo/qu
|
||||
| | | | | |-coll /foo/qux
|
||||
| | | | | | |-route qux /foo/qux
|
||||
| | | |-coll /foo/b
|
||||
| | | | |-coll /foo/ba
|
||||
| | | | | |-coll /foo/bar
|
||||
| | | | | | |-route bar3 /foo/bar
|
||||
|
||||
EOF;
|
||||
|
||||
$this->assertSame($expect, $this->collectionToString($result->getRoot(), ' '));
|
||||
}
|
||||
|
||||
private function collectionToString(DumperCollection $collection, $prefix)
|
||||
{
|
||||
$string = '';
|
||||
foreach ($collection as $route) {
|
||||
if ($route instanceof DumperCollection) {
|
||||
$string .= sprintf("%s|-coll %s\n", $prefix, $route->getPrefix());
|
||||
$string .= $this->collectionToString($route, $prefix.'| ');
|
||||
} else {
|
||||
$string .= sprintf("%s|-route %s %s\n", $prefix, $route->getName(), $route->getRoute()->getPath());
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class LegacyApacheMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $fixturesPath;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
|
||||
}
|
||||
|
||||
public function testDump()
|
||||
{
|
||||
$dumper = new ApacheMatcherDumper($this->getRouteCollection());
|
||||
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.apache', $dumper->dump(), '->dump() dumps basic routes to the correct apache format.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideEscapeFixtures
|
||||
*/
|
||||
public function testEscapePattern($src, $dest, $char, $with, $message)
|
||||
{
|
||||
$r = new \ReflectionMethod(new ApacheMatcherDumper($this->getRouteCollection()), 'escape');
|
||||
$r->setAccessible(true);
|
||||
$this->assertEquals($dest, $r->invoke(null, $src, $char, $with), $message);
|
||||
}
|
||||
|
||||
public function provideEscapeFixtures()
|
||||
{
|
||||
return array(
|
||||
array('foo', 'foo', ' ', '-', 'Preserve string that should not be escaped'),
|
||||
array('fo-o', 'fo-o', ' ', '-', 'Preserve string that should not be escaped'),
|
||||
array('fo o', 'fo- o', ' ', '-', 'Escape special characters'),
|
||||
array('fo-- o', 'fo--- o', ' ', '-', 'Escape special characters'),
|
||||
array('fo- o', 'fo- o', ' ', '-', 'Do not escape already escaped string'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testEscapeScriptName()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('foo', new Route('/foo'));
|
||||
$dumper = new ApacheMatcherDumper($collection);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher2.apache', $dumper->dump(array('script_name' => 'ap p_d\ ev.php')));
|
||||
}
|
||||
|
||||
private function getRouteCollection()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
|
||||
// defaults and requirements
|
||||
$collection->add('foo', new Route(
|
||||
'/foo/{bar}',
|
||||
array('def' => 'test'),
|
||||
array('bar' => 'baz|symfony')
|
||||
));
|
||||
// defaults parameters in pattern
|
||||
$collection->add('foobar', new Route(
|
||||
'/foo/{bar}',
|
||||
array('bar' => 'toto')
|
||||
));
|
||||
// method requirement
|
||||
$collection->add('bar', new Route(
|
||||
'/bar/{foo}',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('GET', 'head')
|
||||
));
|
||||
// method requirement (again)
|
||||
$collection->add('baragain', new Route(
|
||||
'/baragain/{foo}',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('get', 'post')
|
||||
));
|
||||
// simple
|
||||
$collection->add('baz', new Route(
|
||||
'/test/baz'
|
||||
));
|
||||
// simple with extension
|
||||
$collection->add('baz2', new Route(
|
||||
'/test/baz.html'
|
||||
));
|
||||
// trailing slash
|
||||
$collection->add('baz3', new Route(
|
||||
'/test/baz3/'
|
||||
));
|
||||
// trailing slash with variable
|
||||
$collection->add('baz4', new Route(
|
||||
'/test/{foo}/'
|
||||
));
|
||||
// trailing slash and safe method
|
||||
$collection->add('baz5', new Route(
|
||||
'/test/{foo}/',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('GET')
|
||||
));
|
||||
// trailing slash and unsafe method
|
||||
$collection->add('baz5unsafe', new Route(
|
||||
'/testunsafe/{foo}/',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('post')
|
||||
));
|
||||
// complex
|
||||
$collection->add('baz6', new Route(
|
||||
'/test/baz',
|
||||
array('foo' => 'bar baz')
|
||||
));
|
||||
// space in path
|
||||
$collection->add('baz7', new Route(
|
||||
'/te st/baz'
|
||||
));
|
||||
// space preceded with \ in path
|
||||
$collection->add('baz8', new Route(
|
||||
'/te\\ st/baz'
|
||||
));
|
||||
// space preceded with \ in requirement
|
||||
$collection->add('baz9', new Route(
|
||||
'/test/{baz}',
|
||||
array(),
|
||||
array(
|
||||
'baz' => 'te\\\\ st',
|
||||
)
|
||||
));
|
||||
|
||||
$collection1 = new RouteCollection();
|
||||
|
||||
$route1 = new Route('/route1', array(), array(), array(), 'a.example.com');
|
||||
$collection1->add('route1', $route1);
|
||||
|
||||
$collection2 = new RouteCollection();
|
||||
|
||||
$route2 = new Route('/route2', array(), array(), array(), 'a.example.com');
|
||||
$collection2->add('route2', $route2);
|
||||
|
||||
$route3 = new Route('/route3', array(), array(), array(), 'b.example.com');
|
||||
$collection2->add('route3', $route3);
|
||||
|
||||
$collection2->addPrefix('/c2');
|
||||
$collection1->addCollection($collection2);
|
||||
|
||||
$route4 = new Route('/route4', array(), array(), array(), 'a.example.com');
|
||||
$collection1->add('route4', $route4);
|
||||
|
||||
$route5 = new Route('/route5', array(), array(), array(), 'c.example.com');
|
||||
$collection1->add('route5', $route5);
|
||||
|
||||
$route6 = new Route('/route6', array(), array(), array(), null);
|
||||
$collection1->add('route6', $route6);
|
||||
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// host and variables
|
||||
|
||||
$collection1 = new RouteCollection();
|
||||
|
||||
$route11 = new Route('/route11', array(), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route11', $route11);
|
||||
|
||||
$route12 = new Route('/route12', array('var1' => 'val'), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route12', $route12);
|
||||
|
||||
$route13 = new Route('/route13/{name}', array(), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route13', $route13);
|
||||
|
||||
$route14 = new Route('/route14/{name}', array('var1' => 'val'), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route14', $route14);
|
||||
|
||||
$route15 = new Route('/route15/{name}', array(), array(), array(), 'c.example.com');
|
||||
$collection1->add('route15', $route15);
|
||||
|
||||
$route16 = new Route('/route16/{name}', array('var1' => 'val'), array(), array(), null);
|
||||
$collection1->add('route16', $route16);
|
||||
|
||||
$route17 = new Route('/route17', array(), array(), array(), null);
|
||||
$collection1->add('route17', $route17);
|
||||
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
|
@ -1,289 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Routing\Tests\Matcher\Dumper;
|
||||
|
||||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
*/
|
||||
public function testDumpWhenSchemeIsUsedWithoutAProperDumper()
|
||||
{
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('secure', new Route(
|
||||
'/secure',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array('https')
|
||||
));
|
||||
$dumper = new PhpMatcherDumper($collection);
|
||||
$dumper->dump();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getRouteCollections
|
||||
*/
|
||||
public function testDump(RouteCollection $collection, $fixture, $options = array())
|
||||
{
|
||||
$basePath = __DIR__.'/../../Fixtures/dumper/';
|
||||
|
||||
$dumper = new PhpMatcherDumper($collection);
|
||||
$this->assertStringEqualsFile($basePath.$fixture, $dumper->dump($options), '->dump() correctly dumps routes as optimized PHP code.');
|
||||
}
|
||||
|
||||
public function getRouteCollections()
|
||||
{
|
||||
/* test case 1 */
|
||||
|
||||
$collection = new RouteCollection();
|
||||
|
||||
$collection->add('overridden', new Route('/overridden'));
|
||||
|
||||
// defaults and requirements
|
||||
$collection->add('foo', new Route(
|
||||
'/foo/{bar}',
|
||||
array('def' => 'test'),
|
||||
array('bar' => 'baz|symfony')
|
||||
));
|
||||
// method requirement
|
||||
$collection->add('bar', new Route(
|
||||
'/bar/{foo}',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('GET', 'head')
|
||||
));
|
||||
// GET method requirement automatically adds HEAD as valid
|
||||
$collection->add('barhead', new Route(
|
||||
'/barhead/{foo}',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('GET')
|
||||
));
|
||||
// simple
|
||||
$collection->add('baz', new Route(
|
||||
'/test/baz'
|
||||
));
|
||||
// simple with extension
|
||||
$collection->add('baz2', new Route(
|
||||
'/test/baz.html'
|
||||
));
|
||||
// trailing slash
|
||||
$collection->add('baz3', new Route(
|
||||
'/test/baz3/'
|
||||
));
|
||||
// trailing slash with variable
|
||||
$collection->add('baz4', new Route(
|
||||
'/test/{foo}/'
|
||||
));
|
||||
// trailing slash and method
|
||||
$collection->add('baz5', new Route(
|
||||
'/test/{foo}/',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('post')
|
||||
));
|
||||
// complex name
|
||||
$collection->add('baz.baz6', new Route(
|
||||
'/test/{foo}/',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array(),
|
||||
array('put')
|
||||
));
|
||||
// defaults without variable
|
||||
$collection->add('foofoo', new Route(
|
||||
'/foofoo',
|
||||
array('def' => 'test')
|
||||
));
|
||||
// pattern with quotes
|
||||
$collection->add('quoter', new Route(
|
||||
'/{quoter}',
|
||||
array(),
|
||||
array('quoter' => '[\']+')
|
||||
));
|
||||
// space in pattern
|
||||
$collection->add('space', new Route(
|
||||
'/spa ce'
|
||||
));
|
||||
|
||||
// prefixes
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('overridden', new Route('/overridden1'));
|
||||
$collection1->add('foo1', new Route('/{foo}'));
|
||||
$collection1->add('bar1', new Route('/{bar}'));
|
||||
$collection1->addPrefix('/b\'b');
|
||||
$collection2 = new RouteCollection();
|
||||
$collection2->addCollection($collection1);
|
||||
$collection2->add('overridden', new Route('/{var}', array(), array('var' => '.*')));
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('foo2', new Route('/{foo1}'));
|
||||
$collection1->add('bar2', new Route('/{bar1}'));
|
||||
$collection1->addPrefix('/b\'b');
|
||||
$collection2->addCollection($collection1);
|
||||
$collection2->addPrefix('/a');
|
||||
$collection->addCollection($collection2);
|
||||
|
||||
// overridden through addCollection() and multiple sub-collections with no own prefix
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('overridden2', new Route('/old'));
|
||||
$collection1->add('helloWorld', new Route('/hello/{who}', array('who' => 'World!')));
|
||||
$collection2 = new RouteCollection();
|
||||
$collection3 = new RouteCollection();
|
||||
$collection3->add('overridden2', new Route('/new'));
|
||||
$collection3->add('hey', new Route('/hey/'));
|
||||
$collection2->addCollection($collection3);
|
||||
$collection1->addCollection($collection2);
|
||||
$collection1->addPrefix('/multi');
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// "dynamic" prefix
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('foo3', new Route('/{foo}'));
|
||||
$collection1->add('bar3', new Route('/{bar}'));
|
||||
$collection1->addPrefix('/b');
|
||||
$collection1->addPrefix('{_locale}');
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// route between collections
|
||||
$collection->add('ababa', new Route('/ababa'));
|
||||
|
||||
// collection with static prefix but only one route
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('foo4', new Route('/{foo}'));
|
||||
$collection1->addPrefix('/aba');
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// prefix and host
|
||||
|
||||
$collection1 = new RouteCollection();
|
||||
|
||||
$route1 = new Route('/route1', array(), array(), array(), 'a.example.com');
|
||||
$collection1->add('route1', $route1);
|
||||
|
||||
$collection2 = new RouteCollection();
|
||||
|
||||
$route2 = new Route('/c2/route2', array(), array(), array(), 'a.example.com');
|
||||
$collection1->add('route2', $route2);
|
||||
|
||||
$route3 = new Route('/c2/route3', array(), array(), array(), 'b.example.com');
|
||||
$collection1->add('route3', $route3);
|
||||
|
||||
$route4 = new Route('/route4', array(), array(), array(), 'a.example.com');
|
||||
$collection1->add('route4', $route4);
|
||||
|
||||
$route5 = new Route('/route5', array(), array(), array(), 'c.example.com');
|
||||
$collection1->add('route5', $route5);
|
||||
|
||||
$route6 = new Route('/route6', array(), array(), array(), null);
|
||||
$collection1->add('route6', $route6);
|
||||
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// host and variables
|
||||
|
||||
$collection1 = new RouteCollection();
|
||||
|
||||
$route11 = new Route('/route11', array(), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route11', $route11);
|
||||
|
||||
$route12 = new Route('/route12', array('var1' => 'val'), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route12', $route12);
|
||||
|
||||
$route13 = new Route('/route13/{name}', array(), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route13', $route13);
|
||||
|
||||
$route14 = new Route('/route14/{name}', array('var1' => 'val'), array(), array(), '{var1}.example.com');
|
||||
$collection1->add('route14', $route14);
|
||||
|
||||
$route15 = new Route('/route15/{name}', array(), array(), array(), 'c.example.com');
|
||||
$collection1->add('route15', $route15);
|
||||
|
||||
$route16 = new Route('/route16/{name}', array('var1' => 'val'), array(), array(), null);
|
||||
$collection1->add('route16', $route16);
|
||||
|
||||
$route17 = new Route('/route17', array(), array(), array(), null);
|
||||
$collection1->add('route17', $route17);
|
||||
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
// multiple sub-collections with a single route and a prefix each
|
||||
$collection1 = new RouteCollection();
|
||||
$collection1->add('a', new Route('/a...'));
|
||||
$collection2 = new RouteCollection();
|
||||
$collection2->add('b', new Route('/{var}'));
|
||||
$collection3 = new RouteCollection();
|
||||
$collection3->add('c', new Route('/{var}'));
|
||||
$collection3->addPrefix('/c');
|
||||
$collection2->addCollection($collection3);
|
||||
$collection2->addPrefix('/b');
|
||||
$collection1->addCollection($collection2);
|
||||
$collection1->addPrefix('/a');
|
||||
$collection->addCollection($collection1);
|
||||
|
||||
/* test case 2 */
|
||||
|
||||
$redirectCollection = clone $collection;
|
||||
|
||||
// force HTTPS redirection
|
||||
$redirectCollection->add('secure', new Route(
|
||||
'/secure',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array('https')
|
||||
));
|
||||
|
||||
// force HTTP redirection
|
||||
$redirectCollection->add('nonsecure', new Route(
|
||||
'/nonsecure',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'',
|
||||
array('http')
|
||||
));
|
||||
|
||||
/* test case 3 */
|
||||
|
||||
$rootprefixCollection = new RouteCollection();
|
||||
$rootprefixCollection->add('static', new Route('/test'));
|
||||
$rootprefixCollection->add('dynamic', new Route('/{var}'));
|
||||
$rootprefixCollection->addPrefix('rootprefix');
|
||||
$route = new Route('/with-condition');
|
||||
$route->setCondition('context.getMethod() == "GET"');
|
||||
$rootprefixCollection->add('with-condition', $route);
|
||||
|
||||
return array(
|
||||
array($collection, 'url_matcher1.php', array()),
|
||||
array($redirectCollection, 'url_matcher2.php', array('base_class' => 'Symfony\Component\Routing\Tests\Fixtures\RedirectableUrlMatcher')),
|
||||
array($rootprefixCollection, 'url_matcher3.php', array()),
|
||||
);
|
||||
}
|
||||
}
|
Reference in a new issue