You are here

public function EntityFormDisplayAccessControlHandlerTest::testAccess in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php \Drupal\Tests\Core\Entity\Access\EntityFormDisplayAccessControlHandlerTest::testAccess()

@covers ::access @covers ::checkAccess

File

core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php, line 218

Class

EntityFormDisplayAccessControlHandlerTest
@coversDefaultClass \Drupal\Core\Entity\Entity\Access\EntityFormDisplayAccessControlHandler @group Entity

Namespace

Drupal\Tests\Core\Entity\Access

Code

public function testAccess() {
  $this
    ->assertAllowOperations([], $this->anon);
  $this
    ->assertAllowOperations([
    'view',
    'update',
    'delete',
  ], $this->member);
  $this
    ->assertAllowOperations([
    'view',
    'update',
    'delete',
  ], $this->parent_member);
  $this->entity
    ->enforceIsNew(TRUE)
    ->save();

  // Unfortunately, EntityAccessControlHandler has a static cache, which we
  // therefore must reset manually.
  $this->accessControlHandler
    ->resetCache();
  $this
    ->assertAllowOperations([], $this->anon);
  $this
    ->assertAllowOperations([
    'view',
    'update',
  ], $this->member);
  $this
    ->assertAllowOperations([
    'view',
    'update',
  ], $this->parent_member);
}