function RoutePathGenerationTraitTest::setUp
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ RoutePathGenerationTraitTest.php, line 48
Class
- RoutePathGenerationTraitTest
- @covers \Drupal\Core\Access\RoutePathGenerationTrait @group Access
Namespace
Drupal\Tests\Core\AccessCode
protected function setUp() : void {
parent::setUp();
$this->csrfToken = $this->getMockBuilder(CsrfTokenGenerator::class)
->disableOriginalConstructor()
->getMock();
// Make CsrfTokenGenerator mock use a simple hash of the value passed as
// parameter, as it is enough for the sake of our tests.
$this->csrfToken
->method('get')
->willReturnCallback(function ($value) {
return hash('sha256', $value);
});
$this->csrfToken
->method('validate')
->willReturnCallback(function ($token, $value) {
return $token === hash('sha256', $value);
});
$this->requestStack = $this->createMock(RequestStack::class);
$this->processor = new RouteProcessorCsrf($this->csrfToken, $this->requestStack);
$this->accessCheck = new CsrfAccessCheck($this->csrfToken);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.