You are here

protected function UrlGeneratorTest::assertGenerateFromRoute in Zircon Profile 8

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

Asserts \Drupal\Core\Routing\UrlGenerator::generateFromRoute()'s output.

Parameters

$route_name: The route name to test.

array $route_parameters: The route parameters to test.

array $options: The options to test.

$expected_url: The expected generated URL string.

\Drupal\Core\Render\BubbleableMetadata $expected_bubbleable_metadata: The expected generated bubbleable metadata.

6 calls to UrlGeneratorTest::assertGenerateFromRoute()
UrlGeneratorTest::testAbsoluteURLGeneration in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that absolute URLs work with generated routes.
UrlGeneratorTest::testAliasGeneration in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths.
UrlGeneratorTest::testAliasGenerationWithOptions in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths with options.
UrlGeneratorTest::testAliasGenerationWithParameters in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths.
UrlGeneratorTest::testBaseURLGeneration in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that explicitly setting the base_url works with generated routes

... See full list

File

core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php, line 402
Contains \Drupal\Tests\Core\Routing\UrlGeneratorTest.

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

protected function assertGenerateFromRoute($route_name, array $route_parameters, array $options, $expected_url, BubbleableMetadata $expected_bubbleable_metadata) {

  // First, test with $collect_cacheability_metadata set to the default value.
  $url = $this->generator
    ->generateFromRoute($route_name, $route_parameters, $options);
  $this
    ->assertSame($expected_url, $url);

  // Second, test with it set to TRUE.
  $generated_url = $this->generator
    ->generateFromRoute($route_name, $route_parameters, $options, TRUE);
  $this
    ->assertSame($expected_url, $generated_url
    ->getGeneratedUrl());
  $this
    ->assertEquals($expected_bubbleable_metadata, BubbleableMetadata::createFromObject($generated_url));
}