function NodeAccessTestBase::assertNodeAccess

Same name and namespace in other branches
  1. 11.x core/modules/node/tests/src/Kernel/NodeAccessTestBase.php \Drupal\Tests\node\Kernel\NodeAccessTestBase::assertNodeAccess()

Asserts that node access correctly grants or denies access.

@internal

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/Kernel/NodeAccessTestBase.php, line 97

Class

NodeAccessTestBase
Defines a base class for node access kernel tests.

Namespace

Drupal\Tests\node\Kernel

Code

public function assertNodeAccess(array $ops, NodeInterface $node, AccountInterface $account) {
  foreach ($ops as $op => $result) {
    $this->assertEquals($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.