$event =
new ResponseEvent($kernel,
$request, HttpKernelInterface::SUB_REQUEST,
$response);
$this->
expectError();
$dispatcher->
dispatch($event, KernelEvents::RESPONSE
);
} /**
* @covers ::checkRedirectUrl
*/
public function testRedirectWithOptInExternalUrl() { $dispatcher =
new EventDispatcher(\Drupal::
getContainer());
$kernel =
$this->
createMock('Symfony\Component\HttpKernel\HttpKernelInterface'
);
$response =
new TrustedRedirectResponse('http://external-url.com'
);
$request = Request::
create(''
);
$request->headers->
set('HOST', 'example.com'
);
$listener =
new RedirectResponseSubscriber($this->urlAssembler,
$this->requestContext
);
$dispatcher->
addListener(KernelEvents::RESPONSE,
[$listener, 'checkRedirectUrl'
]);
$event =
new ResponseEvent($kernel,
$request, HttpKernelInterface::SUB_REQUEST,
$response);
$dispatcher->
dispatch($event, KernelEvents::RESPONSE
);
$target_url =
$event->
getResponse()->
getTargetUrl();
$this->
assertEquals('http://external-url.com',
$target_url);
}