function AccessResultForbiddenTest::testConstruction

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php \Drupal\Tests\Core\Access\AccessResultForbiddenTest::testConstruction()
  2. 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php \Drupal\Tests\Core\Access\AccessResultForbiddenTest::testConstruction()
  3. 11.x 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 22

Class

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

Namespace

Drupal\Tests\Core\Access

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.