function UrlGeneratorTest::testAbsoluteURLGenerationUsingInterfaceConstants

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

Confirms that absolute URLs work with generated routes using interface constants.

File

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

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testAbsoluteURLGenerationUsingInterfaceConstants() : void {
  $url = $this->generator
    ->generate('test_1', [], UrlGenerator::ABSOLUTE_URL);
  $this->assertEquals('http://localhost/hello/world', $url);
  // No cacheability to test; UrlGenerator::generate() doesn't support
  // collecting cacheability metadata.
  $this->routeProcessorManager
    ->expects($this->exactly(2))
    ->method('processOutbound')
    ->with($this->anything());
  $options = [
    'absolute' => TRUE,
    'fragment' => 'top',
  ];
  // Extra parameters should appear in the query string.
  $this->assertGenerateFromRoute('test_1', [
    'zoo' => 5,
  ], $options, 'http://localhost/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)
    ->setCacheContexts([
    'url.site',
  ]));
}

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