You are here

public function AccessResultForbiddenTest::testSetReason in Drupal 9

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

Tests setReason()

@covers ::setReason

File

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

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public function testSetReason() {
  $a = new AccessResultForbidden();
  $reason = $this
    ->getRandomGenerator()
    ->string();
  $return = $a
    ->setReason($reason);
  $this
    ->assertSame($reason, $a
    ->getReason());
  $this
    ->assertSame($a, $return);
}