You are here

public function CKEditorTest::testJSTranslation in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php \Drupal\Tests\ckeditor\Kernel\CKEditorTest::testJSTranslation()
  2. 9 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 417

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
    ->assertNotEmpty($string, 'String from JavaScript file saved.');

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