public function QueryTest::match

Check a single condition for a single element.

Parameters

array $element: The element which should be checked.

array $condition: An associative array containing:

  • field: The field to by, for example id.
  • value: The expected value of the element.
  • operator: The operator to compare the element value with the expected value.

Return value

bool Returns whether the condition matches with the element.

1 call to QueryTest::match()
QueryTest::execute in drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php
Implements Drupal\views\Plugin\views\query\QueryPluginBase::execute().

File

drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/query/QueryTest.php, line 138
Definition of Drupal\views_test_data\Plugin\views\query\QueryTest.

Class

QueryTest
Defines a query test plugin.

Namespace

Drupal\views_test_data\Plugin\views\query

Code

public function match($element, $condition) {
  $value = $element[$condition['field']];
  switch ($condition['operator']) {
    case '=':
      return $value == $condition['value'];
    case 'IN':
      return in_array($value, $condition['value']);
  }
  return FALSE;
}