You are here

public function EntityQueryAlterComplexTest::testMemberGroupAccessWithPermission in Group 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Kernel/EntityQueryAlterComplexTest.php \Drupal\Tests\group\Kernel\EntityQueryAlterComplexTest::testMemberGroupAccessWithPermission()

Tests that grouped nodes are visible to members.

File

tests/src/Kernel/EntityQueryAlterComplexTest.php, line 126

Class

EntityQueryAlterComplexTest
Tests that Group properly checks access for "complex" grouped entities.

Namespace

Drupal\Tests\group\Kernel

Code

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
    ->assertQueryAccessResult([
    $node_1
      ->id(),
    $node_2
      ->id(),
  ], 'Members can see grouped nodes');
}