function NodeTestBase::assertNodeAccess

Same name in this branch
  1. 8.9.x core/modules/node/src/Tests/NodeTestBase.php \Drupal\node\Tests\NodeTestBase::assertNodeAccess()
Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeTestBase.php \Drupal\Tests\node\Functional\NodeTestBase::assertNodeAccess()
  2. 10 core/modules/node/tests/src/Functional/NodeTestBase.php \Drupal\Tests\node\Functional\NodeTestBase::assertNodeAccess()
  3. 11.x core/modules/node/tests/src/Functional/NodeTestBase.php \Drupal\Tests\node\Functional\NodeTestBase::assertNodeAccess()

Asserts that node access correctly grants or denies access.

Parameters

array $ops: An associative array of the expected node access grants for the node and account, with each key as the name of an operation (e.g. 'view', 'delete') and each value a Boolean indicating whether access to that operation should be granted.

\Drupal\node\NodeInterface $node: The node object to check.

\Drupal\Core\Session\AccountInterface $account: The user account for which to check access.

File

core/modules/node/tests/src/Functional/NodeTestBase.php, line 60

Class

NodeTestBase
Sets up page and article content types.

Namespace

Drupal\Tests\node\Functional

Code

public function assertNodeAccess(array $ops, NodeInterface $node, AccountInterface $account) {
    foreach ($ops as $op => $result) {
        $this->assertEqual($result, $this->accessHandler
            ->access($node, $op, $account), $this->nodeAccessAssertMessage($op, $result, $node->language()
            ->getId()));
    }
}

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