You are here

public function LanguageTest::testCurrentPageLanguageTokenReplacement in Token 8

Tests retrieving the interface and content language from the current page.

@dataProvider currentPageLanguageTokenReplacementDataProvider

File

tests/src/Kernel/LanguageTest.php, line 145

Class

LanguageTest
Tests language tokens.

Namespace

Drupal\Tests\token\Kernel

Code

public function testCurrentPageLanguageTokenReplacement($token, $langcode, $expected_result) {

  // Set the interface language to Dutch.
  $this->languageManager
    ->setCurrentLanguage(LanguageInterface::TYPE_INTERFACE, $this->languages['nl']);

  // Set the content language to Hungarian.
  $this->languageManager
    ->setCurrentLanguage(LanguageInterface::TYPE_CONTENT, $this->languages['hu']);
  $options = $langcode ? [
    'langcode' => $langcode,
  ] : [];
  $result = $this->token
    ->replace($token, [], $options);
  $this
    ->assertEquals($expected_result, $result);
}