function AccessResultTest::testAccessConditionallyAllowed

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

@covers ::allowedIf @covers ::isAllowed @covers ::isForbidden @covers ::isNeutral

File

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

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public function testAccessConditionallyAllowed() : void {
    $verify = function (AccessResult $access, $allowed) {
        $this->assertSame($allowed, $access->isAllowed());
        $this->assertFalse($access->isForbidden());
        $this->assertSame(!$allowed, $access->isNeutral());
        $this->assertDefaultCacheability($access);
    };
    $b1 = AccessResult::allowedIf(TRUE);
    $verify($b1, TRUE);
    $b2 = AccessResult::allowedIf(FALSE);
    $verify($b2, FALSE);
}

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