public function EntityQueryAlterComplexTest::testNonMemberAdminAccess in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/EntityQueryAlterComplexTest.php \Drupal\Tests\group\Kernel\EntityQueryAlterComplexTest::testNonMemberAdminAccess()
Tests the admin access for non-members.
File
- tests/
src/ Kernel/ EntityQueryAlterComplexTest.php, line 440
Class
- EntityQueryAlterComplexTest
- Tests that Group properly checks access for "complex" grouped entities.
Namespace
Drupal\Tests\group\KernelCode
public function testNonMemberAdminAccess() {
$account = $this
->createUser();
$node_1 = $this
->createNode([
'type' => 'page',
]);
$node_2 = $this
->createNode([
'type' => 'page',
'status' => 0,
]);
$node_3 = $this
->createNode([
'type' => 'page',
]);
$node_4 = $this
->createNode([
'type' => 'page',
'status' => 0,
]);
$node_5 = $this
->createNode([
'type' => 'page',
'uid' => $account
->id(),
]);
$node_6 = $this
->createNode([
'type' => 'page',
'status' => 0,
'uid' => $account
->id(),
]);
$this->groupTypeA
->getOutsiderRole()
->grantPermission('administer node_as_content:page')
->save();
$this->groupTypeB
->getOutsiderRole()
->grantPermission('administer node_as_content:page')
->save();
$group_a = $this
->createGroup([
'type' => $this->groupTypeA
->id(),
]);
$group_a
->addContent($node_3, 'node_as_content:page');
$group_a
->addContent($node_4, 'node_as_content:page');
$group_b = $this
->createGroup([
'type' => $this->groupTypeB
->id(),
]);
$group_b
->addContent($node_5, 'node_as_content:page');
$group_b
->addContent($node_6, 'node_as_content:page');
$expected = [
$node_1
->id(),
$node_2
->id(),
$node_3
->id(),
$node_4
->id(),
$node_5
->id(),
$node_6
->id(),
];
$this
->assertQueryAccessResult($expected, 'Admin non-member can see anything regardless of owner or published status.');
}