You are here

protected function RedirectRequestSubscriberTest::getRedirectStub in Redirect 8

Gets the redirect mock object.

Parameters

$url: Url to be returned from getRedirectUrl

int $status_code: The redirect status code.

Return value

PHPUnit_Framework_MockObject_MockObject The mocked redirect object.

2 calls to RedirectRequestSubscriberTest::getRedirectStub()
RedirectRequestSubscriberTest::testRedirectLogicWithoutQueryRetaining in tests/src/Unit/RedirectRequestSubscriberTest.php
@covers ::onKernelRequestCheckRedirect @dataProvider getRedirectData
RedirectRequestSubscriberTest::testRedirectLogicWithQueryRetaining in tests/src/Unit/RedirectRequestSubscriberTest.php
@covers ::onKernelRequestCheckRedirect @dataProvider getRedirectData

File

tests/src/Unit/RedirectRequestSubscriberTest.php, line 229

Class

RedirectRequestSubscriberTest
Tests the redirect logic.

Namespace

Drupal\Tests\redirect\Unit

Code

protected function getRedirectStub($url, $status_code = 301) {
  $redirect = $this
    ->getMockBuilder('Drupal\\redirect\\Entity\\Redirect')
    ->disableOriginalConstructor()
    ->getMock();
  $redirect
    ->expects($this
    ->once())
    ->method('getRedirectUrl')
    ->will($this
    ->returnValue($url));
  $redirect
    ->expects($this
    ->any())
    ->method('getStatusCode')
    ->will($this
    ->returnValue($status_code));
  $redirect
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn(1);
  $redirect
    ->expects($this
    ->once())
    ->method('getCacheTags')
    ->willReturn([
    'redirect:1',
  ]);
  return $redirect;
}