You are here

public function CKEditorTest::testJSTranslation in Drupal 9

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

Tests that CKEditor plugins participate in JS translation.

File

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

Class

CKEditorTest
Tests for the 'CKEditor' text editor plugin.

Namespace

Drupal\Tests\ckeditor\Kernel

Code

public function testJSTranslation() {
  $this
    ->enableModules([
    'language',
    'locale',
  ]);
  $this
    ->installSchema('locale', 'locales_source');
  $this
    ->installSchema('locale', 'locales_location');
  $this
    ->installSchema('locale', 'locales_target');
  $editor = Editor::load('filtered_html');
  $this->ckeditor
    ->getJSSettings($editor);
  $localeStorage = $this->container
    ->get('locale.storage');
  $string = $localeStorage
    ->findString([
    'source' => 'Edit Link',
    'context' => '',
  ]);
  $this
    ->assertTrue(!empty($string), 'String from JavaScript file saved.');

  // With locale module, CKEditor should not adhere to the language selected.
  $this
    ->assertCKEditorLanguage();
}