You are here

public function EntityAccessTest::testMemberGroupAccessWithPermission in Group 8

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

Tests that grouped test entities are visible to members.

File

tests/src/Kernel/EntityAccessTest.php, line 107

Class

EntityAccessTest
Tests that Group properly checks access for grouped entities.

Namespace

Drupal\Tests\group\Kernel

Code

public function testMemberGroupAccessWithPermission() {
  $entity_1 = $this
    ->createTestEntity();
  $entity_2 = $this
    ->createTestEntity();
  $this->groupTypeA
    ->getMemberRole()
    ->grantPermission('administer entity_test_as_content')
    ->save();
  $group = $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $group
    ->addContent($entity_1, 'entity_test_as_content');
  $group
    ->addMember($this
    ->getCurrentUser());
  $this
    ->assertTrue($this->accessControlHandler
    ->access($entity_1, 'view'), 'Members can see grouped test entities.');
  $this
    ->assertTrue($this->accessControlHandler
    ->access($entity_2, 'view'), 'The ungrouped test entity can be viewed.');
}