function AccessResultTest::testAccessForbidden

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbidden()
  2. 10 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbidden()
  3. 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::testAccessForbidden()

@covers ::forbidden @covers ::isAllowed @covers ::isForbidden @covers ::isNeutral

File

core/tests/Drupal/Tests/Core/Access/AccessResultTest.php, line 105

Class

AccessResultTest
@coversDefaultClass \Drupal\Core\Access\AccessResult @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testAccessForbidden() {
    $verify = function (AccessResult $access) {
        $this->assertFalse($access->isAllowed());
        $this->assertTrue($access->isForbidden());
        $this->assertFalse($access->isNeutral());
        $this->assertDefaultCacheability($access);
    };
    // Verify the object when using the ::forbidden() convenience static method.
    $b = AccessResult::forbidden();
    $verify($b);
}

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