/**
* @dataProvider providerTestDestinationRedirectToExternalUrl
*/
public function testDestinationRedirectToExternalUrl($request,
$expected) { $dispatcher =
new EventDispatcher(\Drupal::
getContainer());
$kernel =
$this->
createMock('Symfony\Component\HttpKernel\HttpKernelInterface'
);
$response =
new RedirectResponse('http://other-example.com'
);
$listener =
new RedirectResponseSubscriber($this->urlAssembler,
$this->requestContext
);
$dispatcher->
addListener(KernelEvents::RESPONSE,
[$listener, 'checkRedirectUrl'
]);
$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(''
);