You are here

public function EntityAccessTest::testNonMemberGroupAccessWithoutPermission in Group 2.0.x

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

Tests that grouped test entities are properly hidden.

File

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

Class

EntityAccessTest
Tests that Group properly checks access for grouped entities.

Namespace

Drupal\Tests\group\Kernel

Code

public function testNonMemberGroupAccessWithoutPermission() {
  $entity_1 = $this
    ->createTestEntity();
  $entity_2 = $this
    ->createTestEntity();
  $group = $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $group
    ->addContent($entity_1, 'entity_test_as_content');
  $this
    ->assertFalse($this->accessControlHandler
    ->access($entity_1, 'view'), 'Cannot view the grouped test entity.');
  $this
    ->assertTrue($this->accessControlHandler
    ->access($entity_2, 'view'), 'Only the ungrouped test entity shows up.');
}