public function LanguageTest::currentPageLanguageTokenReplacementDataProvider in Token 8
Provides test data for ::testCurrentPageLanguageTokenReplacement().
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
testCurrentPageLanguageTokenReplacement()
File
- tests/
src/ Kernel/ LanguageTest.php, line 243
Class
- LanguageTest
- Tests language tokens.
Namespace
Drupal\Tests\token\KernelCode
public function currentPageLanguageTokenReplacementDataProvider() {
return [
[
// Test the replacement of the language name token, taken from the
// interface language of the current page.
'[current-page:interface-language:name]',
// We are not overriding the language by passing a language code as an
// option. This means that the language should be taken from the
// interface language which has been set to Dutch.
NULL,
// The expected result.
'Dutch',
],
// Test the token name in the content language.
[
'[current-page:content-language:name]',
NULL,
'Hungarian',
],
// Test the other tokens both for the content and interface languages.
[
'[current-page:interface-language:langcode]',
NULL,
'nl',
],
[
'[current-page:content-language:langcode]',
NULL,
'hu',
],
[
'[current-page:interface-language:direction]',
NULL,
'ltr',
],
[
'[current-page:content-language:direction]',
NULL,
'ltr',
],
[
'[current-page:interface-language:domain]',
NULL,
'nl.example.com',
],
[
'[current-page:content-language:domain]',
NULL,
'hu.example.com',
],
[
'[current-page:interface-language:prefix]',
NULL,
'nl-prefix',
],
[
'[current-page:content-language:prefix]',
NULL,
'hu-prefix',
],
// Now repeat the entire test with Bulgarian passed as an option. This
// should not affect the results, the language should be sourced from the
// current page.
[
// Test the replacement of the language name token, taken from the
// interface language of the current page.
'[current-page:interface-language:name]',
// We are not overriding the language by passing a language code as an
// option. This means that the language should be taken from the
// interface language which has been set to Dutch.
'bg',
// The expected result.
'Dutch',
],
// Test the token name in the content language.
[
'[current-page:content-language:name]',
'bg',
'Hungarian',
],
// Test the other tokens both for the content and interface languages.
[
'[current-page:interface-language:langcode]',
'bg',
'nl',
],
[
'[current-page:content-language:langcode]',
'bg',
'hu',
],
[
'[current-page:interface-language:direction]',
'bg',
'ltr',
],
[
'[current-page:content-language:direction]',
'bg',
'ltr',
],
[
'[current-page:interface-language:domain]',
'bg',
'nl.example.com',
],
[
'[current-page:content-language:domain]',
'bg',
'hu.example.com',
],
[
'[current-page:interface-language:prefix]',
'bg',
'nl-prefix',
],
[
'[current-page:content-language:prefix]',
'bg',
'hu-prefix',
],
];
}