You are here

protected function SearchApiSolrTest::insertMultilingualExampleContent in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x tests/src/Kernel/SearchApiSolrTest.php \Drupal\Tests\search_api_solr\Kernel\SearchApiSolrTest::insertMultilingualExampleContent()

Creates several test entities.

1 call to SearchApiSolrTest::insertMultilingualExampleContent()
SearchApiSolrTest::testLanguageFallbackAndLanguageLimitedByOptions in tests/src/Kernel/SearchApiSolrTest.php
Tests language fallback and language limiting via options.

File

tests/src/Kernel/SearchApiSolrTest.php, line 1235

Class

SearchApiSolrTest
Tests index and search capabilities using the Solr search backend.

Namespace

Drupal\Tests\search_api_solr\Kernel

Code

protected function insertMultilingualExampleContent() {
  $this
    ->addTestEntity(1, [
    'name' => 'en 1',
    'body' => 'gene',
    'type' => 'item',
    'langcode' => 'en',
  ]);
  $this
    ->addTestEntity(2, [
    'name' => 'en 2',
    'body' => 'genes',
    'type' => 'item',
    'langcode' => 'en',
  ]);
  $this
    ->addTestEntity(3, [
    'name' => 'de 3',
    'body' => 'Gen',
    'type' => 'item',
    'langcode' => 'de',
  ]);
  $this
    ->addTestEntity(4, [
    'name' => 'de 4',
    'body' => 'Gen',
    'type' => 'item',
    'langcode' => 'de',
  ]);
  $this
    ->addTestEntity(5, [
    'name' => 'de-at 5',
    'body' => 'Gen',
    'type' => 'item',
    'langcode' => 'de-at',
  ]);
  $this
    ->addTestEntity(6, [
    'name' => 'de-at 6',
    'body' => 'Gen',
    'type' => 'item',
    'langcode' => 'de-at',
  ]);
  $this
    ->addTestEntity(7, [
    'name' => 'und 7',
    'body' => 'gene',
    'type' => 'item',
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ]);
  $this
    ->addTestEntity(8, [
    'name' => 'zxx 8',
    'body' => 'gene',
    'type' => 'item',
    'langcode' => LanguageInterface::LANGCODE_NOT_APPLICABLE,
  ]);
  $count = \Drupal::entityQuery('entity_test_mulrev_changed')
    ->count()
    ->execute();
  $this
    ->assertEquals(8, $count, "{$count} items inserted.");
}