You are here

public function LanguageNegotiationContentEntityTest::testDefaultConfiguration in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php \Drupal\language\Tests\LanguageNegotiationContentEntityTest::testDefaultConfiguration()

Tests default with content language remaining same as interface language.

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

File

core/modules/language/src/Tests/LanguageNegotiationContentEntityTest.php, line 64
Contains \Drupal\language\Tests\LanguageNegotiationLanguageContentEntityTest.

Class

LanguageNegotiationContentEntityTest
Tests language negotiation with the language negotiator content entity.

Namespace

Drupal\language\Tests

Code

public function testDefaultConfiguration() {
  $translation = $this->entity;
  $this
    ->drupalGet($translation
    ->urlInfo());
  $last = $this->container
    ->get('state')
    ->get('language_test.language_negotiation_last');
  $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
  $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
  $this
    ->assertTrue($last_interface_language == $last_content_language && $last_content_language == $translation
    ->language()
    ->getId(), new FormattableMarkup('Interface language %interface_language and Content language %content_language are the same as the translation language %translation_language of the entity.', [
    '%interface_language' => $last_interface_language,
    '%content_language' => $last_content_language,
    '%translation_language' => $translation
      ->language()
      ->getId(),
  ]));
  $translation = $this->entity
    ->getTranslation('es');
  $this
    ->drupalGet($translation
    ->urlInfo());
  $last = $this->container
    ->get('state')
    ->get('language_test.language_negotiation_last');
  $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
  $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
  $this
    ->assertTrue($last_interface_language == $last_content_language && $last_content_language == $translation
    ->language()
    ->getId(), new FormattableMarkup('Interface language %interface_language and Content language %content_language are the same as the translation language %translation_language of the entity.', [
    '%interface_language' => $last_interface_language,
    '%content_language' => $last_content_language,
    '%translation_language' => $translation
      ->language()
      ->getId(),
  ]));
  $translation = $this->entity
    ->getTranslation('fr');
  $this
    ->drupalGet($translation
    ->urlInfo());
  $last = $this->container
    ->get('state')
    ->get('language_test.language_negotiation_last');
  $last_content_language = $last[LanguageInterface::TYPE_CONTENT];
  $last_interface_language = $last[LanguageInterface::TYPE_INTERFACE];
  $this
    ->assertTrue($last_interface_language == $last_content_language && $last_content_language == $translation
    ->language()
    ->getId(), new FormattableMarkup('Interface language %interface_language and Content language %content_language are the same as the translation language %translation_language of the entity.', [
    '%interface_language' => $last_interface_language,
    '%content_language' => $last_content_language,
    '%translation_language' => $translation
      ->language()
      ->getId(),
  ]));
}