You are here

public function QueryAccessHandlerTest::testUpdateDuplicateDelete in Entity API 8

@covers ::getConditions

File

tests/src/Kernel/QueryAccess/QueryAccessHandlerTest.php, line 111

Class

QueryAccessHandlerTest
Tests the query access handler.

Namespace

Drupal\Tests\entity\Kernel\QueryAccess

Code

public function testUpdateDuplicateDelete() {
  foreach ([
    'update',
    'duplicate',
    'delete',
  ] as $operation) {
    $user = $this
      ->createUser([], [
      "{$operation} first entity_test_enhanced",
      "{$operation} second entity_test_enhanced",
    ]);
    $conditions = $this->handler
      ->getConditions($operation, $user);
    $expected_conditions = [
      new Condition('type', [
        'first',
        'second',
      ]),
    ];
    $this
      ->assertEquals('OR', $conditions
      ->getConjunction());
    $this
      ->assertEquals(1, $conditions
      ->count());
    $this
      ->assertEquals($expected_conditions, $conditions
      ->getConditions());
    $this
      ->assertEquals([
      'user.permissions',
    ], $conditions
      ->getCacheContexts());
    $this
      ->assertFalse($conditions
      ->isAlwaysFalse());
  }
}