function CsrfExceptionSubscriberTest::testOn403WithNullRouteDoesNothing

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/EventSubscriber/CsrfExceptionSubscriberTest.php \Drupal\Tests\Core\EventSubscriber\CsrfExceptionSubscriberTest::testOn403WithNullRouteDoesNothing()

Tests on403() with no matched route.

File

core/tests/Drupal/Tests/Core/EventSubscriber/CsrfExceptionSubscriberTest.php, line 26

Class

CsrfExceptionSubscriberTest
Tests Drupal\Core\EventSubscriber\CsrfExceptionSubscriber.

Namespace

Drupal\Tests\Core\EventSubscriber

Code

public function testOn403WithNullRouteDoesNothing() : void {
  $subscriber = new CsrfExceptionSubscriber();
  $request = new Request();
  $kernel = $this->createStub(HttpKernelInterface::class);
  $exception = new AccessDeniedHttpException();
  $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $exception);
  $subscriber->on403($event);
  $this->assertNull($event->getResponse());
}

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