public function CKEditorTest::testBuildToolbarJSSetting in Drupal 10
Same name and namespace in other branches
- 8 core/modules/ckeditor/tests/src/Kernel/CKEditorTest.php \Drupal\Tests\ckeditor\Kernel\CKEditorTest::testBuildToolbarJSSetting()
- 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 227
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
->assertSame($expected, $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
->assertEquals($expected, $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
->assertEquals($expected, $this->ckeditor
->buildToolbarJSSetting($editor), '"toolbar" configuration part of JS settings built correctly for customized toolbar with contrib module-provided CKEditor plugin.');
}