protected function RedirectRequestSubscriberTest::getRedirectRepositoryStub in Redirect 8
Gets the redirect repository mock object.
Parameters
$method: Method to mock - either load() or findMatchingRedirect().
$redirect: The redirect object to be returned.
Return value
PHPUnit_Framework_MockObject_MockObject The redirect repository.
1 call to RedirectRequestSubscriberTest::getRedirectRepositoryStub()
- RedirectRequestSubscriberTest::callOnKernelRequestCheckRedirect in tests/
src/ Unit/ RedirectRequestSubscriberTest.php - Instantiates the subscriber and runs onKernelRequestCheckRedirect()
File
- tests/
src/ Unit/ RedirectRequestSubscriberTest.php, line 195
Class
- RedirectRequestSubscriberTest
- Tests the redirect logic.
Namespace
Drupal\Tests\redirect\UnitCode
protected function getRedirectRepositoryStub($method, $redirect) {
$repository = $this
->getMockBuilder('Drupal\\redirect\\RedirectRepository')
->disableOriginalConstructor()
->getMock();
if ($method === 'findMatchingRedirect') {
$repository
->expects($this
->any())
->method($method)
->willReturnCallback(function ($source_path) use ($redirect) {
// No redirect with source path 'system/files' exists. The stored
// redirect has 'system/files/file.txt' as source path.
return $source_path === 'system/files' ? NULL : $redirect;
});
}
else {
$repository
->expects($this
->any())
->method($method)
->will($this
->returnValue($redirect));
}
return $repository;
}