class CsrfExceptionSubscriberTest

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

Tests Drupal\Core\EventSubscriber\CsrfExceptionSubscriber.

Attributes

#[CoversClass(CsrfExceptionSubscriber::class)] #[Group('EventSubscriber')]

Hierarchy

Expanded class hierarchy of CsrfExceptionSubscriberTest

File

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

Namespace

Drupal\Tests\Core\EventSubscriber
View source
class CsrfExceptionSubscriberTest extends UnitTestCase {
  
  /**
   * Tests on403() with no matched route.
   */
  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.