function AccessResultTest::testAccessAllowed

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

@covers ::allowed @covers ::isAllowed @covers ::isForbidden @covers ::isNeutral

File

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

Class

AccessResultTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Access%21AccessResult.php/class/AccessResult/8.9.x" title="Value object for passing an access result with cacheability metadata." class="local">\Drupal\Core\Access\AccessResult</a> @group Access

Namespace

Drupal\Tests\Core\Access

Code

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

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