You are here

public function GroupContentQueryAccessHandlerTest::testNoAccess in Group 2.0.x

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

Tests that the query has no results for people without any access.

@covers ::getConditions

File

tests/src/Kernel/GroupContentQueryAccessHandlerTest.php, line 87

Class

GroupContentQueryAccessHandlerTest
Tests the behavior of group content query access handler.

Namespace

Drupal\Tests\group\Kernel

Code

public function testNoAccess() {
  $user = new AnonymousUserSession();
  foreach ([
    'view',
    'update',
    'delete',
  ] as $operation) {
    $conditions = $this->handler
      ->getConditions($operation, $user);
    $this
      ->assertEquals(0, $conditions
      ->count());
    $this
      ->assertEqualsCanonicalizing([
      'user.group_permissions',
      'user.permissions',
    ], $conditions
      ->getCacheContexts());
    $this
      ->assertTrue($conditions
      ->isAlwaysFalse());
  }
}