You are here

public function UnroutedUrlAssemblerTest::testAssembleWithEnabledProcessing in Zircon Profile 8

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

@covers ::assemble

File

core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php, line 151
Contains \Drupal\Tests\Core\Utility\UnroutedUrlAssemblerTest.

Class

UnroutedUrlAssemblerTest
@coversDefaultClass \Drupal\Core\Utility\UnroutedUrlAssembler @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public function testAssembleWithEnabledProcessing() {
  $this
    ->setupRequestStack(FALSE);
  $this->pathProcessor
    ->expects($this
    ->exactly(2))
    ->method('processOutbound')
    ->willReturnCallback(function ($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
    if ($bubbleable_metadata) {
      $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);
}