function EntityAccessControlHandlerTest::assertEntityAccess

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::assertEntityAccess()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::assertEntityAccess()
  3. 11.x 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->assertEqual($result, $object->access($op, $account), $message);
    }
}

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