function LanguageTest::test
Same name in this branch
- 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()
Same name in other branches
- 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()
- 9 core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php \Drupal\Tests\ckeditor5\Kernel\LanguageTest::test()
- 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/LanguageTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()
- 10 core/modules/ckeditor5/tests/src/Kernel/LanguageTest.php \Drupal\Tests\ckeditor5\Kernel\LanguageTest::test()
Ensure that languages are resolved correctly.
@dataProvider provider
Parameters
string $drupal_langcode: The language code in Drupal.
string $cke5_langcode: The language code in CKEditor 5.
bool $is_missing_mapping: Whether this mapping is expected to be missing from language.mappings.
File
-
core/
modules/ ckeditor5/ tests/ src/ Kernel/ LanguageTest.php, line 75
Class
- LanguageTest
- Tests language resolving for CKEditor 5.
Namespace
Drupal\Tests\ckeditor5\KernelCode
public function test(string $drupal_langcode, string $cke5_langcode, bool $is_missing_mapping = FALSE) : void {
$editor = Editor::load('basic_html');
ConfigurableLanguage::createFromLangcode($drupal_langcode)->save();
$this->config('system.site')
->set('default_langcode', $drupal_langcode)
->save();
if ($is_missing_mapping) {
// CKEditor 5's UI language falls back to English, until the language
// mapping is expanded.
$settings = $this->ckeditor5
->getJSSettings($editor);
$this->assertSame('en', $settings['language']['ui']);
// Expand the language mapping.
$config = $this->config('language.mappings');
$mapping = $config->get('map');
$mapping += [
$cke5_langcode => $drupal_langcode,
];
$config->set('map', $mapping)
->save();
}
$settings = $this->ckeditor5
->getJSSettings($editor);
$this->assertSame($cke5_langcode, $settings['language']['ui']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.