View source
<?php
namespace Drupal\Tests\ckeditor5\Kernel;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition;
use Drupal\KernelTests\KernelTestBase;
class ConfigurablePluginTest extends KernelTestBase {
protected static $modules = [
'ckeditor5',
'filter',
'editor',
];
protected $manager;
protected function setUp() : void {
parent::setUp();
$this->manager = $this->container
->get('plugin.manager.ckeditor5.plugin');
}
public function testDefaults() {
$all_definitions = $this->manager
->getDefinitions();
$configurable_definitions = array_filter($all_definitions, function (CKEditor5PluginDefinition $definition) : bool {
return $definition
->isConfigurable();
});
$default_plugin_settings = [];
foreach (array_keys($configurable_definitions) as $plugin_name) {
$default_plugin_settings[$plugin_name] = $this->manager
->getPlugin($plugin_name, NULL)
->defaultConfiguration();
}
$expected_default_plugin_settings = [
'ckeditor5_heading' => [
'enabled_headings' => [
'heading2',
'heading3',
'heading4',
'heading5',
'heading6',
],
],
'ckeditor5_style' => [
'styles' => [],
],
'ckeditor5_sourceEditing' => [
'allowed_tags' => [],
],
'ckeditor5_list' => [
'reversed' => TRUE,
'startIndex' => TRUE,
],
'ckeditor5_alignment' => [
'enabled_alignments' => [
0 => 'left',
1 => 'center',
2 => 'right',
3 => 'justify',
],
],
'ckeditor5_imageResize' => [
'allow_resize' => TRUE,
],
'ckeditor5_language' => [
'language_list' => 'un',
],
'ckeditor5_imageUpload' => [],
];
$this
->assertSame($expected_default_plugin_settings, $default_plugin_settings);
}
}