Commit 21d40b75 authored by catch's avatar catch
Browse files

Issue #2581795 by dawehner, smustgrave, YesCT: Add test for UnroutedUrlAssembler::buildLocalUrl()

parent 75110eb0
Loading
Loading
Loading
Loading
+24 −1
Changes for core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php: 24 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ public function testAssembleWithEnabledProcessing() {
        if ($bubbleable_metadata) {
          $bubbleable_metadata->setCacheContexts(['some-cache-context']);
        }
        return 'test-other-uri';
        return '/test-other-uri';
      });

    $result = $this->unroutedUrlAssembler->assemble('base:test-uri', ['path_processing' => TRUE]);
@@ -169,6 +169,29 @@ public function testAssembleWithEnabledProcessing() {
    $this->assertEquals($expected_generated_url, $result);
  }

  /**
   * @covers ::assemble
   */
  public function testAssembleWithStartingSlashEnabledProcessing() {
    $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);
  }

  /**
   * Setups the request stack for a given subdir.
   *