public function NodeOptionPremiumHelperTest::testHasFullAccessWithPermissions in Node Option Premium 8
Tests full access on a premium entity with certain permissions.
@covers ::hasFullAccess @dataProvider accessPermissionsProvider
Parameters
bool $expected: Whether or not access is expected.
string $permission: The permission to check.
File
- tests/
src/ Unit/ NodeOptionPremiumHelperTest.php, line 118
Class
- NodeOptionPremiumHelperTest
- @coversDefaultClass \Drupal\nopremium\NodeOptionPremiumHelper
Namespace
Drupal\Tests\nopremium\UnitCode
public function testHasFullAccessWithPermissions($expected, $permission) {
// Configure that the entity does have a premium field.
$this->entity
->hasField('premium')
->willReturn(TRUE);
// The account has no update access for this entity.
$this->entity
->access('update', $this->account
->reveal())
->willReturn(FALSE);
// Configure the entity to be premium.
$entity = $this->entity
->reveal();
$entity->premium = new \stdClass();
$entity->premium->value = TRUE;
$this->account
->hasPermission(Argument::type('string'))
->will(function ($args) use ($permission) {
return $args[0] === $permission;
});
$this
->assertSame($expected, $this->helper
->hasFullAccess($entity, $this->account
->reveal()));
}