public function RedirectRequestSubscriberTest::testRedirectLogicWithoutQueryRetaining in Redirect 8
@covers ::onKernelRequestCheckRedirect @dataProvider getRedirectData
File
- tests/
src/ Unit/ RedirectRequestSubscriberTest.php, line 74
Class
- RedirectRequestSubscriberTest
- Tests the redirect logic.
Namespace
Drupal\Tests\redirect\UnitCode
public function testRedirectLogicWithoutQueryRetaining($request_uri, $request_query, $redirect_uri) {
$url = $this
->getMockBuilder('Drupal\\Core\\Url')
->disableOriginalConstructor()
->getMock();
$url
->expects($this
->once())
->method('setAbsolute')
->with(TRUE)
->willReturn($url);
// No query retaining, so getOption should not be called.
$url
->expects($this
->never())
->method('getOption');
$url
->expects($this
->never())
->method('setOption');
$url
->expects($this
->once())
->method('toString')
->willReturn($redirect_uri);
$redirect = $this
->getRedirectStub($url);
$event = $this
->callOnKernelRequestCheckRedirect($redirect, $request_uri, $request_query, FALSE);
$this
->assertTrue($event
->getResponse() instanceof RedirectResponse);
$response = $event
->getResponse();
$this
->assertEquals($redirect_uri, $response
->getTargetUrl());
$this
->assertEquals(301, $response
->getStatusCode());
$this
->assertEquals(1, $response->headers
->get('X-Redirect-ID'));
}