You are here

public function EntityAccessControlHandlerTest::assertEntityAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::assertEntityAccess()

Asserts entity access correctly grants or denies access.

5 calls to EntityAccessControlHandlerTest::assertEntityAccess()
EntityAccessControlHandlerTest::testDefaultEntityAccess in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Ensures default entity access is checked when necessary.
EntityAccessControlHandlerTest::testEntityAccess in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Ensures entity access is properly working.
EntityAccessControlHandlerTest::testEntityAccessDefaultController in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Ensures that the default handler is used as a fallback.
EntityAccessControlHandlerTest::testEntityTranslationAccess in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Ensures entity access for entity translations is properly working.
EntityAccessControlHandlerTest::testUserLabelAccess in core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php
Ensures user labels are accessible for everyone.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php, line 42

Class

EntityAccessControlHandlerTest
Tests the entity access control handler.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL) {
  foreach ($ops as $op => $result) {
    $message = new FormattableMarkup("Entity access returns @result with operation '@op'.", [
      '@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
      '@op' => $op,
    ]);
    $this
      ->assertEquals($object
      ->access($op, $account), $result, $message);
  }
}