You are here

public function LanguageIntegrationTest::testLanguageDifferences in Facets 8

Tests facets where the count is different per language.

See also

https://www.drupal.org/node/2827808

File

tests/src/Functional/LanguageIntegrationTest.php, line 227

Class

LanguageIntegrationTest
Tests the integration with the language module.

Namespace

Drupal\Tests\facets\Functional

Code

public function testLanguageDifferences() {
  $entity_test_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_test_mulrev_changed');
  $entity_test_storage
    ->create([
    'name' => 'foo bar baz',
    'body' => 'test test',
    'type' => 'item',
    'keywords' => [
      'orange',
      'lol',
    ],
    'category' => 'item_category',
    'langcode' => 'xx-lolspeak',
  ])
    ->save();
  $entity_test_storage
    ->create([
    'name' => 'foo bar baz',
    'body' => 'test test',
    'type' => 'item',
    'keywords' => [
      'orange',
      'rofl',
    ],
    'category' => 'item_category',
    'langcode' => 'xx-lolspeak',
  ])
    ->save();
  $id = 'water_bear';
  $this
    ->createFacet('Water bear', $id, 'keywords');
  $this
    ->drupalGet('admin/config/search/search-api/index/' . $this->indexId . '/edit');
  $this
    ->assertEquals(2, $this
    ->indexItems($this->indexId), '2 items were indexed.');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetBlocksAppear();
  $this
    ->assertSession()
    ->pageTextContains('orange');
  $this
    ->assertSession()
    ->pageTextContains('grape');
  $this
    ->assertSession()
    ->pageTextContains('rofl');
  $this
    ->drupalPostForm(NULL, [
    'language' => 'xx-lolspeak',
  ], 'Search');
  $this
    ->assertFacetBlocksAppear();
  $this
    ->assertSession()
    ->pageTextContains('orange');
  $this
    ->assertSession()
    ->pageTextContains('rofl');
  $this
    ->assertSession()
    ->pageTextNotContains('grape');
  $this
    ->drupalPostForm(NULL, [
    'language' => 'en',
  ], 'Search');
  $this
    ->assertFacetBlocksAppear();
  $this
    ->assertSession()
    ->pageTextContains('orange');
  $this
    ->assertSession()
    ->pageTextContains('grape');
  $this
    ->assertSession()
    ->pageTextNotContains('rofl');
}