You are here

protected function HighlightTest::createTestField in Search API 8

Creates a field object for testing.

Parameters

string $id: The field ID to set.

string $combined_property_path: The combined property path of the field.

bool $text: (optional) Whether the field should be a fulltext field or not.

Return value

\Drupal\search_api\Item\FieldInterface A field object.

17 calls to HighlightTest::createTestField()
HighlightTest::testExcerptExcludeFields in tests/src/Unit/Processor/HighlightTest.php
Tests excerpts with some fields excluded.
HighlightTest::testFieldExtraction in tests/src/Unit/Processor/HighlightTest.php
Tests that field extraction in the processor works correctly.
HighlightTest::testPostprocessSearchResultsExcerpt in tests/src/Unit/Processor/HighlightTest.php
Tests whether highlighting works on a longer text.
HighlightTest::testPostprocessSearchResultsExcerptStripTags in tests/src/Unit/Processor/HighlightTest.php
Tests whether excerpt creation correctly handles HTML tags.
HighlightTest::testPostprocessSearchResultsExcerptWithKeysFromBackend in tests/src/Unit/Processor/HighlightTest.php
Tests whether excerpt creation uses the "highlighted_keys" extra data.

... See full list

File

tests/src/Unit/Processor/HighlightTest.php, line 1178

Class

HighlightTest
Tests the "Highlight" processor.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

protected function createTestField($id, $combined_property_path, $text = TRUE) {
  $field = new Field($this->index, $id);
  list($datasource_id, $property_path) = Utility::splitCombinedId($combined_property_path);
  $field
    ->setDatasourceId($datasource_id);
  $field
    ->setPropertyPath($property_path);
  $field
    ->setType($text ? 'text' : 'string');
  return $field;
}