You are here

protected function RouteNormalizerRequestSubscriberTest::getUrlGeneratorStub in Redirect 8

Gets the UrlGenerator mock object.

Parameters

string $request_uri: The return value for the generateFromRoute method.

bool $call_expected: If true, we expect generateFromRoute() to be called once.

Return value

\Drupal\Core\Routing\UrlGeneratorInterface|\PHPUnit\Framework\MockObject\MockObject

1 call to RouteNormalizerRequestSubscriberTest::getUrlGeneratorStub()
RouteNormalizerRequestSubscriberTest::getSubscriber in tests/src/Unit/RouteNormalizerRequestSubscriberTest.php
Create a RouteNormalizerRequestSubscriber object.

File

tests/src/Unit/RouteNormalizerRequestSubscriberTest.php, line 141

Class

RouteNormalizerRequestSubscriberTest
Tests the route normalizer.

Namespace

Drupal\Tests\redirect\Unit

Code

protected function getUrlGeneratorStub($request_uri, $call_expected = TRUE) {
  $url_generator = $this
    ->getMockBuilder('\\Drupal\\Core\\Routing\\UrlGeneratorInterface')
    ->getMock();
  $options = [
    'absolute' => TRUE,
  ];
  $expectation = $call_expected ? $this
    ->once() : $this
    ->never();
  $url_generator
    ->expects($expectation)
    ->method('generateFromRoute')
    ->with('<current>', [], $options)
    ->willReturn($request_uri);
  return $url_generator;
}