You are here

public function RouteCollectionTest::testAddDefaultsAndRequirementsAndOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Tests/RouteCollectionTest.php \Symfony\Component\Routing\Tests\RouteCollectionTest::testAddDefaultsAndRequirementsAndOptions()

File

vendor/symfony/routing/Tests/RouteCollectionTest.php, line 114

Class

RouteCollectionTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testAddDefaultsAndRequirementsAndOptions() {
  $collection = new RouteCollection();
  $collection
    ->add('foo', new Route('/{placeholder}'));
  $collection1 = new RouteCollection();
  $collection1
    ->add('bar', new Route('/{placeholder}', array(
    '_controller' => 'fixed',
    'placeholder' => 'default',
  ), array(
    'placeholder' => '.+',
  ), array(
    'option' => 'value',
  )));
  $collection
    ->addCollection($collection1);
  $collection
    ->addDefaults(array(
    'placeholder' => 'new-default',
  ));
  $this
    ->assertEquals(array(
    'placeholder' => 'new-default',
  ), $collection
    ->get('foo')
    ->getDefaults(), '->addDefaults() adds defaults to all routes');
  $this
    ->assertEquals(array(
    '_controller' => 'fixed',
    'placeholder' => 'new-default',
  ), $collection
    ->get('bar')
    ->getDefaults(), '->addDefaults() adds defaults to all routes and overwrites existing ones');
  $collection
    ->addRequirements(array(
    'placeholder' => '\\d+',
  ));
  $this
    ->assertEquals(array(
    'placeholder' => '\\d+',
  ), $collection
    ->get('foo')
    ->getRequirements(), '->addRequirements() adds requirements to all routes');
  $this
    ->assertEquals(array(
    'placeholder' => '\\d+',
  ), $collection
    ->get('bar')
    ->getRequirements(), '->addRequirements() adds requirements to all routes and overwrites existing ones');
  $collection
    ->addOptions(array(
    'option' => 'new-value',
  ));
  $this
    ->assertEquals(array(
    'option' => 'new-value',
    'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler',
  ), $collection
    ->get('bar')
    ->getOptions(), '->addOptions() adds options to all routes and overwrites existing ones');
}