function AddItemToToolbarConfigActionTest::testAddMultipleItemsToToolbar
Same name and namespace in other branches
- main core/modules/ckeditor5/tests/src/Kernel/ConfigAction/AddItemToToolbarConfigActionTest.php \Drupal\Tests\ckeditor5\Kernel\ConfigAction\AddItemToToolbarConfigActionTest::testAddMultipleItemsToToolbar()
Tests adding multiple items to an editor toolbar.
File
-
core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php, line 112
Class
- AddItemToToolbarConfigActionTest
- Tests add item to toolbar config action.
Namespace
Drupal\Tests\ckeditor5\Kernel\ConfigActionCode
public function testAddMultipleItemsToToolbar() : void {
$recipe = $this->createRecipe([
'name' => 'CKEditor 5 multiple toolbar items test',
'config' => [
'actions' => [
'editor.editor.filter_test' => [
'addItemsToToolbar' => [
'sourceEditing',
[
'item_name' => 'italic',
'allow_duplicate' => TRUE,
'position' => 0,
],
],
],
],
],
]);
RecipeRunner::processRecipe($recipe);
/** @var array{toolbar: array{items: string[]}, plugins: array<string, array<mixed>>} $settings */
$settings = Editor::load('filter_test')?->getSettings();
// The `sourceEditing` item should have been appended to the initial
// toolbar, and a duplicate `italic` item inserted at the beginning.
$this->assertSame([
'italic',
'heading',
'bold',
'italic',
'sourceEditing',
], $settings['toolbar']['items']);
// The plugin's default settings should have been added.
$this->assertSame([], $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.