You are here

function NodeTestBase::assertNodeAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeTestBase.php \Drupal\node\Tests\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.

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

File

core/modules/node/src/Tests/NodeTestBase.php, line 64
Contains \Drupal\node\Tests\NodeTestBase.

Class

NodeTestBase
Sets up page and article content types.

Namespace

Drupal\node\Tests

Code

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