You are here

protected function TermAccessTest::assertTermAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Functional/TermAccessTest.php \Drupal\Tests\taxonomy\Functional\TermAccessTest::assertTermAccess()

Checks access on taxonomy term.

Parameters

\Drupal\taxonomy\TermInterface $term: A taxonomy term entity.

$access_operation: The entity operation, e.g. 'view', 'edit', 'delete', etc.

bool $access_allowed: Whether the current use has access to the given operation or not.

string $access_reason: (optional) The reason of the access result.

1 call to TermAccessTest::assertTermAccess()
TermAccessTest::testTermAccess in core/modules/taxonomy/tests/src/Functional/TermAccessTest.php
Tests access control functionality for taxonomy terms.

File

core/modules/taxonomy/tests/src/Functional/TermAccessTest.php, line 120

Class

TermAccessTest
Tests the taxonomy term access permissions.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function assertTermAccess(TermInterface $term, $access_operation, $access_allowed, $access_reason = '') {
  $access_result = $term
    ->access($access_operation, NULL, TRUE);
  $this
    ->assertSame($access_allowed, $access_result
    ->isAllowed());
  if ($access_reason) {
    $this
      ->assertSame($access_reason, $access_result
      ->getReason());
  }
}