You are here

public function EntityQueryAlterComplexTest::testNewGroupContent in Group 2.0.x

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

Tests that adding new group content clears caches.

File

tests/src/Kernel/EntityQueryAlterComplexTest.php, line 474

Class

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

Namespace

Drupal\Tests\group\Kernel

Code

public function testNewGroupContent() {
  $node_1 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $node_2 = $this
    ->createNode([
    'type' => 'page',
  ]);
  $this->groupTypeA
    ->getMemberRole()
    ->grantPermission('view any node_as_content:page entity')
    ->save();
  $group = $this
    ->createGroup([
    'type' => $this->groupTypeA
      ->id(),
  ]);
  $this
    ->assertQueryAccessResult([
    $node_1
      ->id(),
    $node_2
      ->id(),
  ], 'Outsiders can see ungrouped nodes');

  // This should clear the cache.
  $group
    ->addContent($node_1, 'node_as_content:page');
  $this
    ->assertQueryAccessResult([
    $node_2
      ->id(),
  ], 'Outsiders can see ungrouped nodes');
}