You are here

public function NodeAccessTestBase::assertNodeAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Kernel/NodeAccessTestBase.php \Drupal\Tests\node\Kernel\NodeAccessTestBase::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.

6 calls to NodeAccessTestBase::assertNodeAccess()
NodeAccessLanguageAwareCombinationTest::testNodeAccessLanguageAwareCombination in core/modules/node/tests/src/Kernel/NodeAccessLanguageAwareCombinationTest.php
Tests node access and node access queries with multiple node languages.
NodeAccessLanguageAwareTest::testNodeAccessLanguageAware in core/modules/node/tests/src/Kernel/NodeAccessLanguageAwareTest.php
Tests node access and node access queries with multiple node languages.
NodeAccessLanguageTest::testNodeAccess in core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php
Tests node access with multiple node languages and no private nodes.
NodeAccessLanguageTest::testNodeAccessPrivate in core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php
Tests node access with multiple node languages and private nodes.
NodeAccessTest::testNodeAccess in core/modules/node/tests/src/Kernel/NodeAccessTest.php
Runs basic tests for node_access function.

... See full list

File

core/modules/node/tests/src/Kernel/NodeAccessTestBase.php, line 95

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()));
  }
}