You are here

public function EntityAccessComplexTest::testNonMemberGroupAccessWithPermission in Group 8

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

Tests that grouped nodes are visible to non-members.

File

tests/src/Kernel/EntityAccessComplexTest.php, line 148

Class

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

Namespace

Drupal\Tests\group\Kernel

Code

public function testNonMemberGroupAccessWithPermission() {
  $node_1 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $node_2 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $this->groupTypeA
    ->getOutsiderRole()
    ->grantPermission('administer node_as_content:page')
    ->save();
  $group = $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $group
    ->addContent($node_1, 'node_as_content:page');
  $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $this
    ->assertTrue($this->accessControlHandler
    ->access($node_1, 'view'), 'Outsiders can see grouped nodes.');
  $this
    ->assertTrue($this->accessControlHandler
    ->access($node_2, 'view'), 'The node can be viewed.');
}