public function CKEditor5PluginManagerTest::testProvidedElements in Drupal 10
Tests the parsing of CKEditor 5 plugin element config.
@covers \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getProvidedElements @dataProvider providerTestProvidedElements
Parameters
string[] $plugins: The plugins to parse the elements list from.
array $text_editor_settings: The text editor settings.
array $expected_elements: An array of expected allowed elements an attributes in the structure used by filter_html.
string $expected_readable_string: The expected allowed tags and attributes as a string, typically used in the filter_html "Allowed tags" field.
File
- core/
modules/ ckeditor5/ tests/ src/ Kernel/ CKEditor5PluginManagerTest.php, line 1209
Class
- CKEditor5PluginManagerTest
- Tests different ways of enabling CKEditor 5 plugins.
Namespace
Drupal\Tests\ckeditor5\KernelCode
public function testProvidedElements(array $plugins, array $text_editor_settings, array $expected_elements, string $expected_readable_string) {
$this
->enableModules([
'ckeditor5_plugin_elements_test',
]);
$text_editor = Editor::create([
'format' => 'dummy',
'editor' => 'ckeditor5',
'settings' => $text_editor_settings,
'image_upload' => [],
]);
FilterFormat::create([
'format' => 'dummy',
'name' => 'dummy',
])
->save();
$this
->assertConfigSchema($this->typedConfig, $text_editor
->getConfigDependencyName(), $text_editor
->toArray());
$provided_elements = $this->manager
->getProvidedElements($plugins, $text_editor);
$this
->assertSame($expected_elements, $provided_elements);
$this
->assertSame($expected_readable_string, (new HTMLRestrictions($provided_elements))
->toFilterHtmlAllowedTagsString());
}