You are here

public function AccessResultForbiddenTest::testConstruction in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php \Drupal\Tests\Core\Access\AccessResultForbiddenTest::testConstruction()
  2. 9 core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php \Drupal\Tests\Core\Access\AccessResultForbiddenTest::testConstruction()

Tests the construction of an AccessResultForbidden object.

@covers ::__construct @covers ::getReason

File

core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php, line 20

Class

AccessResultForbiddenTest
@coversDefaultClass \Drupal\Core\Access\AccessResultForbidden @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testConstruction() {
  $a = new AccessResultForbidden();
  $this
    ->assertEquals(NULL, $a
    ->getReason());
  $reason = $this
    ->getRandomGenerator()
    ->string();
  $b = new AccessResultForbidden($reason);
  $this
    ->assertEquals($reason, $b
    ->getReason());
}