You are here

protected function SearchApiSortsUpdate8103Test::createSearchApiSortsField in Search API sorts 8

Create a search_api_sorts_field with sensible defaults.

Parameters

string $field: The field identifier.

array $values: An array of values that overrides the defaults.

Return value

\Drupal\search_api_sorts\Entity\SearchApiSortsField The search_api_sorts_field entity.

1 call to SearchApiSortsUpdate8103Test::createSearchApiSortsField()
SearchApiSortsUpdate8103Test::setUp in tests/src/Functional/Update/SearchApiSortsUpdate8103Test.php
Overrides WebTestBase::setUp() for update testing.

File

tests/src/Functional/Update/SearchApiSortsUpdate8103Test.php, line 142

Class

SearchApiSortsUpdate8103Test
Tests the Search api sorts upgrade path for update 8103.

Namespace

Drupal\Tests\search_api_sorts\Functional\Update

Code

protected function createSearchApiSortsField(string $field, array $values = []) : SearchApiSortsField {
  $search_api_sorts_field = SearchApiSortsField::create($values + [
    'id' => sprintf('views_page---search_api_sorts_test_view__page_1_%s', $field),
    'display_id' => 'views_page---search_api_sorts_test_view__page_1',
    'field_identifier' => $field,
    'label' => $field,
    'langcode' => 'en',
    'status' => TRUE,
  ]);
  $search_api_sorts_field
    ->save();
  return $search_api_sorts_field;
}