You are here

public function FieldsProcessorPluginBaseTest::testProcessFieldValueOverride in Search API 8

Tests whether overriding of processFieldValue() works correctly.

File

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

Class

FieldsProcessorPluginBaseTest
Tests the base class for fields-based processors.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

public function testProcessFieldValueOverride() {
  $override = function (&$value, &$type) {

    // Check whether the passed $type matches the one included in the value.
    if (strpos($value, "{$type}_field") !== FALSE) {
      $value = "&{$value}";
    }
    else {
      $value = "/{$value}";
    }
  };
  $this->processor
    ->setMethodOverride('processFieldValue', $override);
  $items = $this
    ->getTestItem();
  $this->processor
    ->preprocessIndexItems($items);
  $this
    ->assertFieldsProcessed($items, [
    'text_field',
    'string_field',
  ], '&');
}