OgAccessTest.php in Organic groups 8
File
tests/src/Unit/OgAccessTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\og\Unit;
class OgAccessTest extends OgAccessTestBase {
public function testUserAccessNotGroup($operation) {
$this->groupTypeManager
->isGroup($this->entityTypeId, $this->bundle)
->willReturn(FALSE);
$user_access = $this->ogAccess
->userAccess($this->group, $operation);
$this
->assertTrue($user_access
->isNeutral());
}
public function testAccessByOperation($operation) {
$user_access = $this->ogAccess
->userAccess($this->group, $operation, $this->user
->reveal());
$condition = $operation == 'update group' ? $user_access
->isAllowed() : $user_access
->isNeutral();
$this
->assertTrue($condition);
}
public function testUserAccessUser1($operation) {
$this->user
->id()
->willReturn(1);
$user_access = $this->ogAccess
->userAccess($this->group, $operation, $this->user
->reveal());
$this
->assertTrue($user_access
->isAllowed());
}
public function testUserAccessAdminPermission($operation) {
$this->user
->hasPermission('administer organic groups')
->willReturn(TRUE);
$user_access = $this->ogAccess
->userAccess($this->group, $operation, $this->user
->reveal());
$this
->assertTrue($user_access
->isAllowed());
}
public function testUserAccessOwner($operation) {
$this->config
->get('group_manager_full_access')
->willReturn(TRUE);
$user_access = $this->ogAccess
->userAccess($this
->groupEntity(TRUE)
->reveal(), $operation, $this->user
->reveal());
$this
->assertTrue($user_access
->isAllowed());
}
}