You are here

public function FieldsProcessorPluginBaseTest::testProcessKeysComplex in Search API 8

Tests whether preprocessing of complex search keys works correctly.

File

tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php, line 425

Class

FieldsProcessorPluginBaseTest
Tests the base class for fields-based processors.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

public function testProcessKeysComplex() {
  $query = \Drupal::getContainer()
    ->get('search_api.query_helper')
    ->createQuery($this->index);
  $keys =& $query
    ->getKeys();
  $keys = [
    '#conjunction' => 'OR',
    'foo',
    [
      '#conjunction' => 'AND',
      'bar',
      'baz',
      '#negation' => TRUE,
    ],
  ];
  $this->processor
    ->preprocessSearchQuery($query);
  $expected = [
    '#conjunction' => 'OR',
    '*foo',
    [
      '#conjunction' => 'AND',
      '*bar',
      '*baz',
      '#negation' => TRUE,
    ],
  ];
  $this
    ->assertEquals($expected, $query
    ->getKeys(), 'Search keys were correctly preprocessed.');
}