You are here

protected function BackendTestBase::regressionTest2471509 in Search API 8

Regression tests for strings longer than 50 chars.

See also

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

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

1 call to BackendTestBase::regressionTest2471509()
BackendTestBase::regressionTests2 in tests/src/Kernel/BackendTestBase.php
Executes regression tests which are unpractical to run in between.

File

tests/src/Kernel/BackendTestBase.php, line 992

Class

BackendTestBase
Provides a base class for backend tests.

Namespace

Drupal\Tests\search_api\Kernel

Code

protected function regressionTest2471509() {
  $this
    ->addTestEntity(8, [
    'name' => 'Article with long body',
    'type' => 'article',
    'body' => 'astringlongerthanfiftycharactersthatcantbestoredbythedbbackend',
  ]);
  $count = $this
    ->indexItems($this->indexId);
  $this
    ->assertEquals(1, $count, 'Indexing an item with a word longer than 50 characters worked.');
  $index = $this
    ->getIndex();
  $index
    ->getField('body')
    ->setType('string');
  $index
    ->save();
  $count = $this
    ->indexItems($this->indexId);
  $this
    ->assertEquals(count($this->entities), $count, 'Switching type from text to string worked.');

  // For a string field, 50 characters shouldn't be a problem.
  $query = $this
    ->buildSearch(NULL, [
    'body,astringlongerthanfiftycharactersthatcantbestoredbythedbbackend',
  ]);
  $results = $query
    ->execute();
  $this
    ->assertResults([
    8,
  ], $results, 'Filter on new string field');
  $index
    ->getField('body')
    ->setType('text');
  $index
    ->save();
  $count = $this
    ->indexItems($this->indexId);
  $this
    ->assertEquals(count($this->entities), $count, 'All items needed to be re-indexed after switching type from string to text.');
}