You are here

public function EntityAccessComplexTest::testMemberGroupAccessWithoutPermission in Group 8

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

Tests that grouped nodes are properly hidden.

File

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

Class

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

Namespace

Drupal\Tests\group\Kernel

Code

public function testMemberGroupAccessWithoutPermission() {
  $node_1 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $node_2 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $group = $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $group
    ->addContent($node_1, 'node_as_content:page');
  $group
    ->addMember($this
    ->getCurrentUser());
  $this
    ->assertFalse($this->accessControlHandler
    ->access($node_1, 'view'), 'Cannot view the grouped node.');
  $this
    ->assertTrue($this->accessControlHandler
    ->access($node_2, 'view'), 'Only the ungrouped node shows up.');
}