function EntityFormDisplayAccessControlHandlerTest::testAccess

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()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php \Drupal\Tests\Core\Entity\Access\EntityFormDisplayAccessControlHandlerTest::testAccess()
  3. 11.x 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[[api-linebreak]] @group Entity

Namespace

Drupal\Tests\Core\Entity\Access

Code

public function testAccess() : void {
  $this->assertAllowOperations([], $this->anon);
  $this->assertAllowOperations([
    'view',
    'update',
    'delete',
  ], $this->member);
  $this->assertAllowOperations([
    'view',
    'update',
    'delete',
  ], $this->parentMember);
  $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->parentMember);
}

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