function AccessResultTest::testAccessForbiddenReason
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbiddenReason()
- 10 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbiddenReason()
- 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbiddenReason()
@covers ::forbidden
File
-
core/
tests/ Drupal/ Tests/ Core/ Access/ AccessResultTest.php, line 122
Class
- AccessResultTest
- @coversDefaultClass \Drupal\Core\Access\AccessResult @group Access
Namespace
Drupal\Tests\Core\AccessCode
public function testAccessForbiddenReason() {
$verify = function (AccessResult $access, $reason) {
$this->assertInstanceOf(AccessResultReasonInterface::class, $access);
$this->assertSame($reason, $access->getReason());
};
$b = AccessResult::forbidden();
$verify($b, '');
$reason = $this->getRandomGenerator()
->string();
$b = AccessResult::forbidden($reason);
$verify($b, $reason);
$b = AccessResult::forbiddenIf(TRUE, $reason);
$verify($b, $reason);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.