function CKEditorTest::testBuildToolbarJSSetting
Same name in other branches
- 9 core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php \Drupal\Tests\ckeditor\Kernel\CKEditorTest::testBuildToolbarJSSetting()
Tests CKEditor::buildToolbarJSSetting().
File
-
core/
modules/ ckeditor/ tests/ src/ Kernel/ CKEditorTest.php, line 228
Class
- CKEditorTest
- Tests for the 'CKEditor' text editor plugin.
Namespace
Drupal\Tests\ckeditor\KernelCode
public function testBuildToolbarJSSetting() {
$editor = Editor::load('filtered_html');
// Default toolbar.
$expected = $this->getDefaultToolbarConfig();
$this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor
->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for default toolbar.');
// Customize the configuration.
$settings = $editor->getSettings();
$settings['toolbar']['rows'][0][0]['items'][] = 'Strike';
$editor->setSettings($settings);
$editor->save();
$expected[0]['items'][] = 'Strike';
$this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor
->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
// Enable the editor_test module, customize further.
$this->enableModules([
'ckeditor_test',
]);
$this->container
->get('plugin.manager.ckeditor.plugin')
->clearCachedDefinitions();
// Override the label of a toolbar component.
$settings['toolbar']['rows'][0][0]['name'] = 'JunkScience';
$settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
$editor->setSettings($settings);
$editor->save();
$expected[0]['name'] = 'JunkScience';
$expected[0]['items'][] = 'Llama';
$this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor
->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.