function RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl()
  2. 10 core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl()
  3. 8.9.x core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirectToExternalUrl()

@dataProvider providerTestDestinationRedirectToExternalUrl

File

core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php, line 118

Class

RedirectResponseSubscriberTest
@coversDefaultClass \Drupal\Core\EventSubscriber\RedirectResponseSubscriber[[api-linebreak]] @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.