public function GroupQueryAccessHandlerTest::testOnlyGroupTypeDeleteAccess in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/GroupQueryAccessHandlerTest.php \Drupal\Tests\group\Kernel\GroupQueryAccessHandlerTest::testOnlyGroupTypeDeleteAccess()
Tests the conditions for people with update access in just the type scope.
@covers ::getConditions
File
- tests/
src/ Kernel/ GroupQueryAccessHandlerTest.php, line 126
Class
- GroupQueryAccessHandlerTest
- Tests the behavior of group query access handler.
Namespace
Drupal\Tests\group\KernelCode
public function testOnlyGroupTypeDeleteAccess() {
$user = $this
->getCurrentUser();
$this->entityTypeManager
->getStorage('group_role')
->load('default-outsider')
->grantPermission('delete group')
->revokePermission('view group')
->save();
$conditions = $this->handler
->getConditions('delete', $user);
$expected_conditions = [
new Condition('type', [
'default',
]),
];
$this
->assertEquals(1, $conditions
->count());
$this
->assertEquals($expected_conditions, $conditions
->getConditions());
$this
->assertEquals([
'user.group_permissions',
'user.permissions',
], $conditions
->getCacheContexts());
$this
->assertFalse($conditions
->isAlwaysFalse());
foreach ([
'view',
'update',
] as $operation) {
$conditions = $this->handler
->getConditions($operation, $user);
$this
->assertEquals(0, $conditions
->count());
$this
->assertEquals([
'user.group_permissions',
'user.permissions',
], $conditions
->getCacheContexts());
$this
->assertTrue($conditions
->isAlwaysFalse());
}
}