function TermAccessTest::assertTermAccess

Same name in other branches
  1. 8.9.x core/modules/taxonomy/tests/src/Functional/TermAccessTest.php \Drupal\Tests\taxonomy\Functional\TermAccessTest::assertTermAccess()
  2. 10 core/modules/taxonomy/tests/src/Functional/TermAccessTest.php \Drupal\Tests\taxonomy\Functional\TermAccessTest::assertTermAccess()
  3. 11.x core/modules/taxonomy/tests/src/Functional/TermAccessTest.php \Drupal\Tests\taxonomy\Functional\TermAccessTest::assertTermAccess()

Checks access on taxonomy term.

@internal

Parameters

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

string $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 122

Class

TermAccessTest
Tests the taxonomy term access permissions.

Namespace

Drupal\Tests\taxonomy\Functional

Code

protected function assertTermAccess(TermInterface $term, string $access_operation, bool $access_allowed, string $access_reason = '') : void {
    $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());
    }
}

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