function UrlGeneratorTest::testUrlGenerationWithHttpsRequirement

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

Tests the 'scheme' route requirement during URL generation.

File

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

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',
    ]));
}

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