OgAccessEntityTest.php in Organic groups 8
File
tests/src/Unit/OgAccessEntityTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\og\Unit;
class OgAccessEntityTest extends OgAccessEntityTestBase {
public function testAccessByPermission($permission) {
$this->membershipManager
->getGroups($this->groupContentEntity
->reveal())
->willReturn([
$this->entityTypeId => [
$this->group,
],
]);
$user_access = $this->ogAccess
->userAccessEntity($permission, $this->groupContentEntity
->reveal(), $this->user
->reveal());
$condition = $permission == 'update group' ? $user_access
->isAllowed() : $user_access
->isNeutral();
$this
->assertTrue($condition);
}
public function testAccessByPermissionAdmin($permission) {
$this->membershipManager
->getGroups($this->groupContentEntity
->reveal())
->willReturn([
$this->entityTypeId => [
$this->group,
],
]);
$this->user
->hasPermission('administer organic groups')
->willReturn(TRUE);
$user_entity_access = $this->ogAccess
->userAccessEntity($permission, $this->groupContentEntity
->reveal(), $this->user
->reveal());
$this
->assertTrue($user_entity_access
->isAllowed());
}
}