You are here

public function NodeOptionPremiumHelperTest::testNoAccessAsNonOwner in Node Option Premium 8

Tests that non-owners have no access.

@covers ::hasFullAccess

File

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

Class

NodeOptionPremiumHelperTest
@coversDefaultClass \Drupal\nopremium\NodeOptionPremiumHelper

Namespace

Drupal\Tests\nopremium\Unit

Code

public function testNoAccessAsNonOwner() {
  $node = $this
    ->createPremiumNode();

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

  // The account is authenticated.
  $this->account
    ->isAuthenticated()
    ->willReturn(TRUE);

  // The entity's owner ID and the account ID aren't the same.
  $node
    ->getOwnerId()
    ->willReturn(3);
  $this->account
    ->id()
    ->willReturn(4);

  // The account has no update access for this entity.
  $node
    ->access('update', $this->account
    ->reveal())
    ->willReturn(FALSE);

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