function RouteCompilerTest::testCompilation

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php \Drupal\Tests\Core\Routing\RouteCompilerTest::testCompilation()
  2. 8.9.x core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php \Drupal\Tests\Core\Routing\RouteCompilerTest::testCompilation()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php \Drupal\Tests\Core\Routing\RouteCompilerTest::testCompilation()

Confirms that a route compiles properly with the necessary data.

File

core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php, line 57

Class

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

Namespace

Drupal\Tests\Core\Routing

Code

public function testCompilation() : void {
    $route = new Route('/test/{something}/more');
    $route->setOption('compiler_class', RouteCompiler::class);
    $compiled = $route->compile();
    $this->assertEquals(5, $compiled->getFit(), 'The fit was incorrect.');
    $this->assertEquals('/test/%/more', $compiled->getPatternOutline(), 'The pattern outline was not correct.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.