CsrfExceptionSubscriberTest.php
Same filename and directory in other branches
Namespace
Drupal\Tests\Core\EventSubscriberFile
-
core/
tests/ Drupal/ Tests/ Core/ EventSubscriber/ CsrfExceptionSubscriberTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\Core\EventSubscriber;
use Drupal\Core\EventSubscriber\CsrfExceptionSubscriber;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Tests Drupal\Core\EventSubscriber\CsrfExceptionSubscriber.
*/
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());
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| CsrfExceptionSubscriberTest | Tests Drupal\Core\EventSubscriber\CsrfExceptionSubscriber. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.