You are here

public function UrlGeneratorTest::testUrlGenerationWithHttpsRequirement 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::testUrlGenerationWithHttpsRequirement()

Test that the 'scheme' route requirement is respected during url generation.

File

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

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testUrlGenerationWithHttpsRequirement() {
  $url = $this->generator
    ->generate('test_4', [], TRUE);
  $this
    ->assertEquals('https://localhost/test/four', $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,
    'https' => TRUE,
  ];
  $this
    ->assertGenerateFromRoute('test_1', [], $options, 'https://localhost/hello/world', (new BubbleableMetadata())
    ->setCacheMaxAge(Cache::PERMANENT)
    ->setCacheContexts([
    'url.site',
  ]));
}