You are here

public function EntityAccessControlHandlerTest::testAccess in Entity API 8

@covers ::checkAccess @covers ::checkEntityPermissions @covers ::checkEntityOwnerPermissions @covers ::checkCreateAccess

@dataProvider accessProvider

File

tests/src/Unit/EntityAccessControlHandlerTest.php, line 54

Class

EntityAccessControlHandlerTest
@coversDefaultClass \Drupal\entity\EntityAccessControlHandler @group entity

Namespace

Drupal\Tests\entity\Unit

Code

public function testAccess(EntityInterface $entity, $operation, $account, $allowed, $cache_contexts) {
  $handler = new EntityAccessControlHandler($entity
    ->getEntityType());
  $handler
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $result = $handler
    ->access($entity, $operation, $account, TRUE);
  $this
    ->assertEquals($allowed, $result
    ->isAllowed());
  $this
    ->assertEquals($cache_contexts, $result
    ->getCacheContexts());
}