You are here

public function RedirectResponseSubscriberTest::testDestinationRedirectWithInvalidUrl in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest::testDestinationRedirectWithInvalidUrl()

@expectedException \PHPUnit_Framework_Error

@dataProvider providerTestDestinationRedirectWithInvalidUrl

File

core/tests/Drupal/Tests/Core/EventSubscriber/RedirectResponseSubscriberTest.php, line 177
Contains \Drupal\Tests\Core\EventSubscriber\RedirectResponseSubscriberTest.

Class

RedirectResponseSubscriberTest
@coversDefaultClass \Drupal\Core\EventSubscriber\RedirectResponseSubscriber @group EventSubscriber

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public function testDestinationRedirectWithInvalidUrl(Request $request) {
  $dispatcher = new EventDispatcher();
  $kernel = $this
    ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
  $response = new RedirectResponse('http://example.com/drupal');
  $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());
}