public function RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl()
@dataProvider providerTestDestinationRedirectToExternalUrl
@expectedException \PHPUnit_Framework_Error
File
- core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ RedirectResponseSubscriberTest.php, line 126 - Contains \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest.
Class
- RedirectResponseSubscriberTest
- @coversDefaultClass \Drupal\Core\EventSubscriber\RedirectResponseSubscriber @group EventSubscriber
Namespace
Drupal\Tests\Core\EventSubscriberCode
public function testDestinationRedirectToExternalUrl($request, $expected) {
$dispatcher = new EventDispatcher();
$kernel = $this
->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
$response = new RedirectResponse('http://other-example.com');
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
$dispatcher
->addListener(KernelEvents::RESPONSE, array(
$listener,
'checkRedirectUrl',
));
$event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher
->dispatch(KernelEvents::RESPONSE, $event);
$this
->assertEquals(400, $event
->getResponse()
->getStatusCode());
}