You are here

protected function CKEditorTest::assertCKEditorLanguage in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php \Drupal\Tests\ckeditor\Kernel\CKEditorTest::assertCKEditorLanguage()

Assert that CKEditor picks the expected language when French is default.

Parameters

string $langcode: Language code to assert for. Defaults to French. That is the default language set in this assertion.

2 calls to CKEditorTest::assertCKEditorLanguage()
CKEditorTest::testJSTranslation in core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
Tests that CKEditor plugins participate in JS translation.
CKEditorTest::testLanguages in core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php
Tests language list availability in CKEditor.

File

core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php, line 426

Class

CKEditorTest
Tests for the 'CKEditor' text editor plugin.

Namespace

Drupal\Tests\ckeditor\Kernel

Code

protected function assertCKEditorLanguage($langcode = 'fr') {

  // Set French as the site default language.
  ConfigurableLanguage::createFromLangcode('fr')
    ->save();
  $this
    ->config('system.site')
    ->set('default_langcode', 'fr')
    ->save();

  // Reset the language manager so new negotiations attempts will fall back on
  // French. Reinject the language manager CKEditor to use the current one.
  $this->container
    ->get('language_manager')
    ->reset();
  $this->ckeditor = $this->container
    ->get('plugin.manager.editor')
    ->createInstance('ckeditor');

  // Test that we now get the expected language.
  $editor = Editor::load('filtered_html');
  $settings = $this->ckeditor
    ->getJSSettings($editor);
  $this
    ->assertEqual($settings['language'], $langcode);
}