function AddItemToToolbarConfigActionTest::testAddItemToToolbar
Tests add item to toolbar.
Attributes
#[TestWith([
"sourceEditing",
[
"heading",
"bold",
"italic",
"sourceEditing",
],
])]
#[TestWith([
[
"item_name" => "sourceEditing",
],
[
"heading",
"bold",
"italic",
"sourceEditing",
],
])]
#[TestWith([
[
"item_name" => "sourceEditing",
"position" => 1,
],
[
"heading",
"sourceEditing",
"bold",
"italic",
],
])]
#[TestWith([
[
"item_name" => "sourceEditing",
"position" => 1,
"replace" => TRUE,
],
[
"heading",
"sourceEditing",
"italic",
],
])]
#[TestWith([
[
"item_name" => "bold",
],
[
"heading",
"bold",
"italic",
],
])]
#[TestWith([
[
"item_name" => "bold",
"allow_duplicate" => TRUE,
],
[
"heading",
"bold",
"italic",
"bold",
],
])]
Parameters
string|array<string, mixed> $action: The value to pass to the config action.
string[] $expected_toolbar_items: The items which should be in the editor toolbar, in the expected order.
File
-
core/
modules/ ckeditor5/ tests/ src/ Kernel/ ConfigAction/ AddItemToToolbarConfigActionTest.php, line 77
Class
- AddItemToToolbarConfigActionTest
- Tests add item to toolbar config action.
Namespace
Drupal\Tests\ckeditor5\Kernel\ConfigActionCode
public function testAddItemToToolbar(string|array $action, array $expected_toolbar_items) : void {
$recipe = $this->createRecipe([
'name' => 'CKEditor 5 toolbar item test',
'config' => [
'actions' => [
'editor.editor.filter_test' => [
'addItemToToolbar' => $action,
],
],
],
]);
RecipeRunner::processRecipe($recipe);
/** @var array{toolbar: array{items: string[]}, plugins: array<string, array<mixed>>} $settings */
$settings = Editor::load('filter_test')?->getSettings();
$this->assertSame($expected_toolbar_items, $settings['toolbar']['items']);
// The plugin's default settings should have been added.
if (in_array('sourceEditing', $expected_toolbar_items, TRUE)) {
$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.