You are here

public function QueryAccessEventTest::testEvent in Entity API 8

Tests the event.

File

tests/src/Kernel/QueryAccess/QueryAccessEventTest.php, line 66

Class

QueryAccessEventTest
Tests the query access event.

Namespace

Drupal\Tests\entity\Kernel\QueryAccess

Code

public function testEvent() {

  // By default, the first user should have full access, and the second
  // user should have no access. The QueryAccessSubscriber flips that.
  $first_user = $this
    ->createUser([
    'mail' => 'user1@example.com',
  ], [
    'administer entity_test_enhanced',
  ]);
  $second_user = $this
    ->createUser([
    'mail' => 'user2@example.com',
  ]);
  $conditions = $this->handler
    ->getConditions('view', $first_user);
  $this
    ->assertTrue($conditions
    ->isAlwaysFalse());
  $conditions = $this->handler
    ->getConditions('view', $second_user);
  $this
    ->assertFalse($conditions
    ->isAlwaysFalse());
}