function LanguageNegotiationContentEntityTest::testDefaultConfiguration

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::testDefaultConfiguration()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::testDefaultConfiguration()
  3. 11.x core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php \Drupal\Tests\language\Functional\LanguageNegotiationContentEntityTest::testDefaultConfiguration()

Tests default with content language remaining same as interface language.

1 call to LanguageNegotiationContentEntityTest::testDefaultConfiguration()
LanguageNegotiationContentEntityTest::testEnabledLanguageContentNegotiator in core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php
Tests enabling the language negotiator language_content_entity.

File

core/modules/language/tests/src/Functional/LanguageNegotiationContentEntityTest.php, line 70

Class

LanguageNegotiationContentEntityTest
Tests language negotiation with the language negotiator content entity.

Namespace

Drupal\Tests\language\Functional

Code

public function testDefaultConfiguration() : void {
    $translation = $this->entity;
    $this->drupalGet($translation->toUrl());
    $last = \Drupal::keyValue('language_test')->get('language_negotiation_last');
    $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
    $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
    $this->assertSame($last_content_language, $last_interface_language);
    $this->assertSame($translation->language()
        ->getId(), $last_content_language);
    $translation = $this->entity
        ->getTranslation('es');
    $this->drupalGet($translation->toUrl());
    $last = \Drupal::keyValue('language_test')->get('language_negotiation_last');
    $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
    $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
    $this->assertSame($last_content_language, $last_interface_language);
    $this->assertSame($translation->language()
        ->getId(), $last_content_language);
    $translation = $this->entity
        ->getTranslation('fr');
    $this->drupalGet($translation->toUrl());
    $last = \Drupal::keyValue('language_test')->get('language_negotiation_last');
    $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
    $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
    $this->assertSame($last_content_language, $last_interface_language);
    $this->assertSame($translation->language()
        ->getId(), $last_content_language);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.