function CsrfAccessCheckTest::testAccessTokenPass
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testAccessTokenPass()
- 10 core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testAccessTokenPass()
- 11.x core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php \Drupal\Tests\Core\Access\CsrfAccessCheckTest::testAccessTokenPass()
Tests the access() method with a valid token.
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ CsrfAccessCheckTest.php, line 51
Class
- CsrfAccessCheckTest
- @coversDefaultClass \Drupal\Core\Access\CsrfAccessCheck @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAccessTokenPass() {
$this->csrfToken
->expects($this->once())
->method('validate')
->with('test_query', 'test-path/42')
->will($this->returnValue(TRUE));
$this->routeMatch
->expects($this->once())
->method('getRawParameters')
->will($this->returnValue([
'node' => 42,
]));
$route = new Route('/test-path/{node}', [], [
'_csrf_token' => 'TRUE',
]);
$request = Request::create('/test-path/42?token=test_query');
$this->assertEquals(AccessResult::allowed()->setCacheMaxAge(0), $this->accessCheck
->access($route, $request, $this->routeMatch));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.