You are here

public function EntityAccessTest::testNonMemberGroupAccessWithPermission in Group 8

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

Tests that grouped test entities are visible to non-members.

File

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

Class

EntityAccessTest
Tests that Group properly checks access for grouped entities.

Namespace

Drupal\Tests\group\Kernel

Code

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