public function EntityAccessComplexTest::testMemberGroupAccessWithPermission in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/EntityAccessComplexTest.php \Drupal\Tests\group\Kernel\EntityAccessComplexTest::testMemberGroupAccessWithPermission()
Tests that grouped nodes are visible to members.
File
- tests/
src/ Kernel/ EntityAccessComplexTest.php, line 132
Class
- EntityAccessComplexTest
- Tests that Group properly checks access for "complex" grouped entities.
Namespace
Drupal\Tests\group\KernelCode
public function testMemberGroupAccessWithPermission() {
$node_1 = $this
->createNode([
'type' => 'page',
]);
$node_2 = $this
->createNode([
'type' => 'page',
]);
$this->groupTypeA
->getMemberRole()
->grantPermission('administer node_as_content:page')
->save();
$group = $this
->createGroup([
'type' => $this->groupTypeA
->id(),
]);
$group
->addContent($node_1, 'node_as_content:page');
$group
->addMember($this
->getCurrentUser());
$this
->assertTrue($this->accessControlHandler
->access($node_1, 'view'), 'Members can see grouped nodes.');
$this
->assertTrue($this->accessControlHandler
->access($node_2, 'view'), 'The ungrouped node can be viewed.');
}