You are here

protected function BackendTest::regressionTest3199355 in Search API 8

Tests whether string field values with trailing spaces work correctly.

See also

https://www.drupal.org/node/3199355

1 call to BackendTest::regressionTest3199355()
BackendTest::backendSpecificRegressionTests in modules/search_api_db/tests/src/Kernel/BackendTest.php
Runs backend specific regression tests.

File

modules/search_api_db/tests/src/Kernel/BackendTest.php, line 831

Class

BackendTest
Tests index and search capabilities using the Database search backend.

Namespace

Drupal\Tests\search_api_db\Kernel

Code

protected function regressionTest3199355() {

  // Index all items before adding a new one, so we can better predict the
  // expected count.
  $this
    ->indexItems($this->indexId);
  $entity_id = count($this->entities) + 1;
  $entity = $this
    ->addTestEntity($entity_id, [
    'keywords' => [
      'foo',
      'foo ',
      ' foo',
      ' foo ',
    ],
    'type' => 'article',
  ]);
  $count = $this
    ->indexItems($this->indexId);
  $this
    ->assertEquals(1, $count);
  $results = $this
    ->buildSearch()
    ->addCondition('keywords', 'foo ')
    ->execute();
  $this
    ->assertResults([
    $entity_id,
  ], $results, 'String filter with trailing space');
  $entity
    ->delete();
  unset($this->entities[$entity_id]);
}