public function EntityQueryAlterTest::testMemberGroupAccessWithPermission in Group 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/EntityQueryAlterTest.php \Drupal\Tests\group\Kernel\EntityQueryAlterTest::testMemberGroupAccessWithPermission()
 
Tests that grouped test entities are visible to members.
File
- tests/
src/ Kernel/ EntityQueryAlterTest.php, line 106  
Class
- EntityQueryAlterTest
 - Tests that Group properly checks access for grouped entities.
 
Namespace
Drupal\Tests\group\KernelCode
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
    ->assertQueryAccessResult([
    $entity_1
      ->id(),
    $entity_2
      ->id(),
  ], 'Members can see grouped test entities');
}