public function AccessResultTest::testAccessForbiddenReason in Drupal 9
Same name and namespace in other branches
- 8 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()
@covers ::forbidden
File
- core/
tests/ Drupal/ Tests/ Core/ Access/ AccessResultTest.php, line 119 - Contains \Drupal\Tests\Core\Access\AccessResultTest.
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, NULL);
$reason = $this
->getRandomGenerator()
->string();
$b = AccessResult::forbidden($reason);
$verify($b, $reason);
$b = AccessResult::forbiddenIf(TRUE, $reason);
$verify($b, $reason);
}