You are here

public function UrlGeneratorTest::testAliasGeneration in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testAliasGeneration()

Confirms that generated routes will have aliased paths.

File

core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php, line 207

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testAliasGeneration() {
  $url = $this->generator
    ->generate('test_1');
  $this
    ->assertEquals('/hello/world', $url);

  // No cacheability to test; UrlGenerator::generate() doesn't support
  // collecting cacheability metadata.
  $this->routeProcessorManager
    ->expects($this
    ->exactly(3))
    ->method('processOutbound')
    ->with($this
    ->anything());

  // Check that the two generate methods return the same result.
  $this
    ->assertGenerateFromRoute('test_1', [], [], $url, (new BubbleableMetadata())
    ->setCacheMaxAge(Cache::PERMANENT));
  $path = $this->generator
    ->getPathFromRoute('test_1');
  $this
    ->assertEquals('test/one', $path);
}