You are here

public function EntityAccessControlHandlerTest::testEntityWithUuidAccessCache in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::testEntityWithUuidAccessCache()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest::testEntityWithUuidAccessCache()

Ensures the static access cache works correctly with a UUID and revisions.

See also

entity_test_entity_access()

File

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

Class

EntityAccessControlHandlerTest
Tests the entity access control handler.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityWithUuidAccessCache() {
  $account = $this
    ->createUser();
  $entity1 = EntityTestRev::create([
    'name' => 'Accessible',
  ]);
  $entity1
    ->save();
  $entity2 = EntityTestRev::create([
    'name' => 'Inaccessible',
  ]);
  $entity2
    ->save();
  $this
    ->assertTrue($entity1
    ->access('delete', $account), 'Entity 1 can be deleted.');
  $this
    ->assertFalse($entity2
    ->access('delete', $account), 'Entity 2 CANNOT be deleted.');
  $entity1
    ->setName('Inaccessible')
    ->setNewRevision();
  $entity1
    ->save();
  $this
    ->assertFalse($entity1
    ->access('delete', $account), 'Entity 1 revision 2 CANNOT be deleted.');
}