public function CsrfAccessCheckTest::testAccessTokenPass 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::testAccessTokenPass()
Tests the access() method with a valid token.
File
- core/
tests/ Drupal/ Tests/ Core/ Access/ CsrfAccessCheckTest.php, line 56 - Contains \Drupal\Tests\Core\Access\CsrfAccessCheckTest.
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(array(
'node' => 42,
)));
$route = new Route('/test-path/{node}', array(), array(
'_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));
}