You are here

public function QueryAccessEventTest::testGenericEvent in Entity API 8

Tests the generic event.

File

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

Class

QueryAccessEventTest
Tests the query access event.

Namespace

Drupal\Tests\entity\Kernel\QueryAccess

Code

public function testGenericEvent() {
  $entity_type_manager = $this->container
    ->get('entity_type.manager');
  $entity_type = $entity_type_manager
    ->getDefinition('entity_test_enhanced_with_owner');
  $handler = QueryAccessHandler::createInstance($this->container, $entity_type);
  $first_user = $this
    ->createUser([
    'mail' => 'user9000@example.com',
  ]);
  $conditions = $handler
    ->getConditions('view', $first_user);
  $this
    ->assertTrue($conditions
    ->isAlwaysFalse());
  $second_user = $this
    ->createUser([
    'mail' => 'user9001@example.com',
  ]);
  $conditions = $handler
    ->getConditions('view', $second_user);
  $this
    ->assertFalse($conditions
    ->isAlwaysFalse());
}