function UrlGeneratorTest::assertGenerateFromRoute

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

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

@internal

Parameters

string $route_name: The route name to test.

array $route_parameters: The route parameters to test.

array $options: The options to test.

string $expected_url: The expected generated URL string.

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

9 calls to UrlGeneratorTest::assertGenerateFromRoute()
UrlGeneratorTest::testAbsoluteURLGeneration in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that absolute URLs work with generated routes.
UrlGeneratorTest::testAbsoluteURLGenerationUsingInterfaceConstants in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that absolute URLs work with generated routes using interface constants.
UrlGeneratorTest::testAliasGeneration in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths.
UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths using interface constants.
UrlGeneratorTest::testAliasGenerationWithOptions in core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php
Confirms that generated routes will have aliased paths with options.

... See full list

File

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

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

protected function assertGenerateFromRoute(string $route_name, array $route_parameters, array $options, string $expected_url, BubbleableMetadata $expected_bubbleable_metadata) : void {
    // 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));
}

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