You are here

public function RouteCompilerTest::testCompilationDefaultValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php \Drupal\Tests\Core\Routing\RouteCompilerTest::testCompilationDefaultValue()

Confirms that a compiled route with default values has the correct outline.

File

core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php, line 72
Contains \Drupal\Tests\Core\Routing\RouteCompilerTest.

Class

RouteCompilerTest
@coversDefaultClass \Drupal\Core\Routing\RouteCompiler @group Routing

Namespace

Drupal\Tests\Core\Routing

Code

public function testCompilationDefaultValue() {

  // Because "here" has a default value, it should not factor into the outline
  // or the fitness.
  $route = new Route('/test/{something}/more/{here}', array(
    'here' => 'there',
  ));
  $route
    ->setOption('compiler_class', 'Drupal\\Core\\Routing\\RouteCompiler');
  $compiled = $route
    ->compile();
  $this
    ->assertEquals($compiled
    ->getFit(), 5, 'The fit was not correct.');
  $this
    ->assertEquals($compiled
    ->getPatternOutline(), '/test/%/more', 'The pattern outline was not correct.');
}