You are here

public function ConditionTest::testIn in Apigee Edge 8

Tests an array contains ("IN" keyword in SQL) condition.

File

tests/src/Unit/ConditionTest.php, line 85

Class

ConditionTest
Entity query condition tests.

Namespace

Drupal\Tests\apigee_edge\Unit

Code

public function testIn() {
  $values = [];
  for ($i = 0; $i < 16; $i++) {
    $values[] = $this
      ->randomData()[1];
  }
  $cond = $this
    ->mockCondition();
  $cond
    ->condition('foo_bar', $values, 'IN');
  $this
    ->assertFilters($cond, function (EntityInterface $item) use ($values) : bool {
    $item_value = $item
      ->getFooBar();
    foreach ($values as $value) {
      if ($item_value === $value) {
        return TRUE;
      }
    }
    return FALSE;
  });
}