protected function SerializationTest::createTestItem in Search API 8
Creates an item for testing purposes.
Return value
\Drupal\search_api\Item\ItemInterface A test item.
3 calls to SerializationTest::createTestItem()
- SerializationTest::testItemCloning in tests/src/ Kernel/ System/ SerializationTest.php 
- Tests that cloning of items works correctly.
- SerializationTest::testItemSerialization in tests/src/ Kernel/ System/ SerializationTest.php 
- Tests that serialization of items works correctly.
- SerializationTest::testResultSerialization in tests/src/ Kernel/ System/ SerializationTest.php 
- Tests that serialization of search results works correctly.
File
- tests/src/ Kernel/ System/ SerializationTest.php, line 301 
Class
- SerializationTest
- Tests that various classes can be properly serialized and/or cloned.
Namespace
Drupal\Tests\search_api\Kernel\SystemCode
protected function createTestItem() {
  $item = new Item($this->index, 'entity:node/id');
  $item
    ->setBoost(2);
  $item
    ->setExcerpt('Foo bar baz');
  $item
    ->setExtraData('foo', (object) [
    'bar' => 1,
  ]);
  $item
    ->setExtraData('test', 1);
  $item
    ->setLanguage('en');
  $item
    ->setScore(4);
  $item
    ->setFields([
    'test' => $this
      ->createTestField(),
    'foo' => $this
      ->createTestField('foo', 'entity:entity_test_mulrev_changed'),
  ]);
  $item
    ->setFieldsExtracted(TRUE);
  return $item;
}