function UnroutedUrlAssemblerTest::testAssembleWithStartingSlashEnabledProcessing

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest::testAssembleWithStartingSlashEnabledProcessing()

@covers ::assemble

File

core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php, line 177

Class

UnroutedUrlAssemblerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Utility%21UnroutedUrlAssembler.php/class/UnroutedUrlAssembler/11.x" title="Provides a way to build external or non Drupal local domain URLs." class="local">\Drupal\Core\Utility\UnroutedUrlAssembler</a> @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public function testAssembleWithStartingSlashEnabledProcessing() : void {
    $this->setupRequestStack(FALSE);
    $this->pathProcessor
        ->expects($this->exactly(2))
        ->method('processOutbound')
        ->with('/test-uri', $this->anything(), $this->anything(), $this->anything())
        ->willReturnCallback(function ($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
        $bubbleable_metadata?->setCacheContexts([
            'some-cache-context',
        ]);
        return '/test-other-uri';
    });
    $result = $this->unroutedUrlAssembler
        ->assemble('base:/test-uri', [
        'path_processing' => TRUE,
    ]);
    $this->assertEquals('/test-other-uri', $result);
    $result = $this->unroutedUrlAssembler
        ->assemble('base:/test-uri', [
        'path_processing' => TRUE,
    ], TRUE);
    $expected_generated_url = new GeneratedUrl();
    $expected_generated_url->setGeneratedUrl('/test-other-uri')
        ->setCacheContexts([
        'some-cache-context',
    ]);
    $this->assertEquals($expected_generated_url, $result);
}

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