public function RedirectResponseSubscriberTest::testSanitizeDestinationForGet 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::testSanitizeDestinationForGet()
Tests that $_GET only contain internal URLs.
@covers ::sanitizeDestination
@dataProvider providerTestSanitizeDestination
See also
\Drupal\Component\Utility\UrlHelper::isExternal
File
- core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ RedirectResponseSubscriberTest.php, line 215 - Contains \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest.
Class
- RedirectResponseSubscriberTest
- @coversDefaultClass \Drupal\Core\EventSubscriber\RedirectResponseSubscriber @group EventSubscriber
Namespace
Drupal\Tests\Core\EventSubscriberCode
public function testSanitizeDestinationForGet($input, $output) {
$request = new Request();
$request->query
->set('destination', $input);
$listener = new RedirectResponseSubscriber($this->urlAssembler, $this->requestContext);
$kernel = $this
->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$dispatcher = new EventDispatcher();
$dispatcher
->addListener(KernelEvents::REQUEST, [
$listener,
'sanitizeDestination',
], 100);
$dispatcher
->dispatch(KernelEvents::REQUEST, $event);
$this
->assertEquals($output, $request->query
->get('destination'));
}