public function CsrfAccessCheckTest::testAccessTokenFail in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testAccessTokenFail()
Tests the access() method with an invalid token.
File
- core/
tests/ Drupal/ Tests/ Core/ Access/ CsrfAccessCheckTest.php, line 75 - Contains \Drupal\Tests\Core\Access\CsrfAccessCheckTest.
Class
- CsrfAccessCheckTest
- @coversDefaultClass \Drupal\Core\Access\CsrfAccessCheck @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAccessTokenFail() {
$this->csrfToken
->expects($this
->once())
->method('validate')
->with('test_query', 'test-path')
->will($this
->returnValue(FALSE));
$this->routeMatch
->expects($this
->once())
->method('getRawParameters')
->will($this
->returnValue(array()));
$route = new Route('/test-path', array(), array(
'_csrf_token' => 'TRUE',
));
$request = Request::create('/test-path?token=test_query');
$this
->assertEquals(AccessResult::forbidden()
->setCacheMaxAge(0), $this->accessCheck
->access($route, $request, $this->routeMatch));
}