You are here

public function LanguageTest::languageTokenReplacementDataProvider in Token 8

Provides test data for ::testLanguageTokenReplacement().

Return value

array An array of test cases. Each test case is an array with the following values:

  • The token to test.
  • An optional language code to pass as an option.
  • The expected result of the token replacement.

See also

testLanguageTokenReplacement()

File

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

Class

LanguageTest
Tests language tokens.

Namespace

Drupal\Tests\token\Kernel

Code

public function languageTokenReplacementDataProvider() {
  return [
    [
      // Test the replacement of the name of the site default language.
      '[language:name]',
      // We are not overriding the language by passing a language code as an
      // option. This means that the default language should be used which has
      // been set to Portuguese.
      NULL,
      // The expected result.
      'Portuguese, Portugal',
    ],
    // Test the replacement of the other properties of the default language.
    [
      '[language:langcode]',
      NULL,
      'pt-pt',
    ],
    [
      '[language:direction]',
      NULL,
      'ltr',
    ],
    [
      '[language:domain]',
      NULL,
      'pt-pt.example.com',
    ],
    [
      '[language:prefix]',
      NULL,
      'pt-pt-prefix',
    ],
    // Now repeat the entire test but override the language to use by passing
    // Bulgarian as an option.
    [
      '[language:name]',
      'bg',
      'Bulgarian',
    ],
    [
      '[language:langcode]',
      'bg',
      'bg',
    ],
    [
      '[language:direction]',
      'bg',
      'ltr',
    ],
    [
      '[language:domain]',
      'bg',
      'bg.example.com',
    ],
    [
      '[language:prefix]',
      'bg',
      'bg-prefix',
    ],
  ];
}