public function CsrfAccessCheckTest::testCsrfTokenMissing in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testCsrfTokenMissing()
- 10 core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testCsrfTokenMissing()
@covers ::access
File
- core/
tests/ Drupal/ Tests/ Core/ Access/ CsrfAccessCheckTest.php, line 89
Class
- CsrfAccessCheckTest
- @coversDefaultClass \Drupal\Core\Access\CsrfAccessCheck @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testCsrfTokenMissing() {
$this->csrfToken
->expects($this
->once())
->method('validate')
->with('', 'test-path')
->will($this
->returnValue(FALSE));
$this->routeMatch
->expects($this
->once())
->method('getRawParameters')
->will($this
->returnValue([]));
$route = new Route('/test-path', [], [
'_csrf_token' => 'TRUE',
]);
$request = Request::create('/test-path');
$this
->assertEquals(AccessResult::forbidden("'csrf_token' URL query argument is missing.")
->setCacheMaxAge(0), $this->accessCheck
->access($route, $request, $this->routeMatch));
}