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