You are here

protected function CKEditorTest::assertCKEditorLanguage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/ckeditor/src/Tests/CKEditorTest.php \Drupal\ckeditor\Tests\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/src/Tests/CKEditorTest.php
Tests that CKEditor plugins participate in JS translation.
CKEditorTest::testLanguages in core/modules/ckeditor/src/Tests/CKEditorTest.php
Tests language list availability in CKEditor.

File

core/modules/ckeditor/src/Tests/CKEditorTest.php, line 406
Contains \Drupal\ckeditor\Tests\CKEditorTest.

Class

CKEditorTest
Tests for the 'CKEditor' text editor plugin.

Namespace

Drupal\ckeditor\Tests

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);
}