You are here

public function RouteTest::testConstructor in Zircon Profile 8

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

File

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

Class

RouteTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testConstructor() {
  $route = new Route('/{foo}', array(
    'foo' => 'bar',
  ), array(
    'foo' => '\\d+',
  ), array(
    'foo' => 'bar',
  ), '{locale}.example.com');
  $this
    ->assertEquals('/{foo}', $route
    ->getPath(), '__construct() takes a path as its first argument');
  $this
    ->assertEquals(array(
    'foo' => 'bar',
  ), $route
    ->getDefaults(), '__construct() takes defaults as its second argument');
  $this
    ->assertEquals(array(
    'foo' => '\\d+',
  ), $route
    ->getRequirements(), '__construct() takes requirements as its third argument');
  $this
    ->assertEquals('bar', $route
    ->getOption('foo'), '__construct() takes options as its fourth argument');
  $this
    ->assertEquals('{locale}.example.com', $route
    ->getHost(), '__construct() takes a host pattern as its fifth argument');
  $route = new Route('/', array(), array(), array(), '', array(
    'Https',
  ), array(
    'POST',
    'put',
  ), 'context.getMethod() == "GET"');
  $this
    ->assertEquals(array(
    'https',
  ), $route
    ->getSchemes(), '__construct() takes schemes as its sixth argument and lowercases it');
  $this
    ->assertEquals(array(
    'POST',
    'PUT',
  ), $route
    ->getMethods(), '__construct() takes methods as its seventh argument and uppercases it');
  $this
    ->assertEquals('context.getMethod() == "GET"', $route
    ->getCondition(), '__construct() takes a condition as its eight argument');
  $route = new Route('/', array(), array(), array(), '', 'Https', 'Post');
  $this
    ->assertEquals(array(
    'https',
  ), $route
    ->getSchemes(), '__construct() takes a single scheme as its sixth argument');
  $this
    ->assertEquals(array(
    'POST',
  ), $route
    ->getMethods(), '__construct() takes a single method as its seventh argument');
}