You are here

public function UrlGeneratorTest::testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing 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::testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing()
  2. 10 core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php \Drupal\Tests\Core\Routing\UrlGeneratorTest::testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing()

@covers ::generateFromRoute

File

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

Class

UrlGeneratorTest
Confirm that the UrlGenerator is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing() {
  $path_processor = $this
    ->prophesize(OutboundPathProcessorInterface::class);
  $path_processor
    ->processOutbound('/test/one', Argument::cetera())
    ->willReturn('/hello/world')
    ->shouldBeCalled();
  $provider = $this
    ->prophesize(RouteProviderInterface::class);
  $provider
    ->getRouteByName('test_1')
    ->willReturn(new Route('/test/one', [], [], [
    'default_url_options' => [
      'path_processing' => FALSE,
    ],
  ]));
  $generator = new UrlGenerator($provider
    ->reveal(), $path_processor
    ->reveal(), $this->routeProcessorManager, $this->requestStack, [
    'http',
    'https',
  ]);
  $generator
    ->setContext($this->context);
  $url = $generator
    ->generateFromRoute('test_1', [], [
    'path_processing' => TRUE,
  ]);
  $this
    ->assertEquals('/hello/world', $url);
}