function CKEditorTest::testJSTranslation

Same name in other branches
  1. 8.9.x 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 421

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.