You are here

public function NodeOptionPremiumHelperTest::testHasFullAccessAsEditor in Node Option Premium 8

Tests that an user who may edit the entity, has access.

@covers ::hasFullAccess

File

tests/src/Unit/NodeOptionPremiumHelperTest.php, line 158

Class

NodeOptionPremiumHelperTest
@coversDefaultClass \Drupal\nopremium\NodeOptionPremiumHelper

Namespace

Drupal\Tests\nopremium\Unit

Code

public function testHasFullAccessAsEditor() {

  // Configure that the entity does have a premium field.
  $this->entity
    ->hasField('premium')
    ->willReturn(TRUE);

  // The account has none of the permissions.
  $this->account
    ->hasPermission(Argument::type('string'))
    ->wilLReturn(FALSE);

  // The account does have update access for this entity.
  $this->entity
    ->access('update', $this->account
    ->reveal())
    ->willReturn(TRUE);

  // Configure the entity to be premium.
  $entity = $this->entity
    ->reveal();
  $entity->premium = new \stdClass();
  $entity->premium->value = TRUE;
  $this
    ->assertTrue($this->helper
    ->hasFullAccess($entity, $this->account
    ->reveal()));
}