You are here

public function RouteTest::testDefaults in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/routing/Tests/RouteTest.php \Symfony\Component\Routing\Tests\RouteTest::testDefaults()

File

vendor/symfony/routing/Tests/RouteTest.php, line 75

Class

RouteTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testDefaults() {
  $route = new Route('/{foo}');
  $route
    ->setDefaults(array(
    'foo' => 'bar',
  ));
  $this
    ->assertEquals(array(
    'foo' => 'bar',
  ), $route
    ->getDefaults(), '->setDefaults() sets the defaults');
  $this
    ->assertEquals($route, $route
    ->setDefaults(array()), '->setDefaults() implements a fluent interface');
  $route
    ->setDefault('foo', 'bar');
  $this
    ->assertEquals('bar', $route
    ->getDefault('foo'), '->setDefault() sets a default value');
  $route
    ->setDefault('foo2', 'bar2');
  $this
    ->assertEquals('bar2', $route
    ->getDefault('foo2'), '->getDefault() return the default value');
  $this
    ->assertNull($route
    ->getDefault('not_defined'), '->getDefault() return null if default value is not set');
  $route
    ->setDefault('_controller', $closure = function () {
    return 'Hello';
  });
  $this
    ->assertEquals($closure, $route
    ->getDefault('_controller'), '->setDefault() sets a default value');
  $route
    ->setDefaults(array(
    'foo' => 'foo',
  ));
  $route
    ->addDefaults(array(
    'bar' => 'bar',
  ));
  $this
    ->assertEquals($route, $route
    ->addDefaults(array()), '->addDefaults() implements a fluent interface');
  $this
    ->assertEquals(array(
    'foo' => 'foo',
    'bar' => 'bar',
  ), $route
    ->getDefaults(), '->addDefaults() keep previous defaults');
}