You are here

protected function FieldsProcessorPluginBaseTest::getTestItem in Search API 8

Returns an array with one test item suitable for this test case.

Parameters

string[]|null $types: (optional) The types of fields to create. Defaults to using "text", "string", "integer" and "float".

Return value

\Drupal\search_api\Item\ItemInterface[] An array containing one item.

5 calls to FieldsProcessorPluginBaseTest::getTestItem()
FieldsProcessorPluginBaseTest::setUp in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Creates a new processor object for use in the tests.
FieldsProcessorPluginBaseTest::testProcessFieldValueOverride in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Tests whether overriding of processFieldValue() works correctly.
FieldsProcessorPluginBaseTest::testTestField in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Tests whether selecting fields works correctly.
FieldsProcessorPluginBaseTest::testTestTypeDefault in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Tests whether the default implementation of testType() works correctly.
FieldsProcessorPluginBaseTest::testTestTypeOverride in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
Tests whether overriding of testType() works correctly.

File

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

Class

FieldsProcessorPluginBaseTest
Tests the base class for fields-based processors.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

protected function getTestItem($types = NULL) {
  if ($types === NULL) {
    $types = [
      'text',
      'string',
      'integer',
      'float',
    ];
  }
  $fields = [];
  foreach ($types as $type) {
    $field_id = "{$type}_field";
    $fields[$field_id] = [
      'type' => $type,
      'values' => [
        "{$field_id} value 1",
        "{$field_id} value 2",
      ],
    ];
  }
  return $this
    ->createItems($this->index, 1, $fields);
}