function ConfigurablePluginTest::testDefaults

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php \Drupal\Tests\ckeditor5\Kernel\ConfigurablePluginTest::testDefaults()
  2. 10 core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php \Drupal\Tests\ckeditor5\Kernel\ConfigurablePluginTest::testDefaults()

Tests default settings for configurable CKEditor 5 plugins.

File

core/modules/ckeditor5/tests/src/Kernel/ConfigurablePluginTest.php, line 49

Class

ConfigurablePluginTest
Tests configurable plugins.

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function testDefaults() : void {
    $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_codeBlock' => [
            'languages' => [
                [
                    'language' => 'plaintext',
                    'label' => 'Plain text',
                ],
                [
                    'language' => 'c',
                    'label' => 'C',
                ],
                [
                    'language' => 'cs',
                    'label' => 'C#',
                ],
                [
                    'language' => 'cpp',
                    'label' => 'C++',
                ],
                [
                    'language' => 'css',
                    'label' => 'CSS',
                ],
                [
                    'language' => 'diff',
                    'label' => 'Diff',
                ],
                [
                    'language' => 'html',
                    'label' => 'HTML',
                ],
                [
                    'language' => 'java',
                    'label' => 'Java',
                ],
                [
                    'language' => 'javascript',
                    'label' => 'JavaScript',
                ],
                [
                    'language' => 'php',
                    'label' => 'PHP',
                ],
                [
                    'language' => 'python',
                    'label' => 'Python',
                ],
                [
                    'language' => 'ruby',
                    'label' => 'Ruby',
                ],
                [
                    'language' => 'typescript',
                    'label' => 'TypeScript',
                ],
                [
                    'language' => 'xml',
                    'label' => 'XML',
                ],
            ],
        ],
        'ckeditor5_list' => [
            'properties' => [
                'reversed' => TRUE,
                'startIndex' => TRUE,
            ],
            'multiBlock' => TRUE,
        ],
        'ckeditor5_alignment' => [
            'enabled_alignments' => [
                0 => 'left',
                1 => 'center',
                2 => 'right',
                3 => 'justify',
            ],
        ],
        'ckeditor5_image' => [],
        'ckeditor5_imageResize' => [
            'allow_resize' => TRUE,
        ],
        'ckeditor5_language' => [
            'language_list' => 'un',
        ],
    ];
    $this->assertSame($expected_default_plugin_settings, $default_plugin_settings);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.