function CKEditor5PluginManagerTest::providerTestProvidedElements

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5PluginManagerTest::providerTestProvidedElements()
  2. 11.x core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5PluginManagerTest::providerTestProvidedElements()

Provides uses cases enabling different elements and the expected results.

File

core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php, line 1263

Class

CKEditor5PluginManagerTest
Tests different ways of enabling CKEditor 5 plugins.

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function providerTestProvidedElements() : array {
    $text_align_classes = [
        'text-align-left' => TRUE,
        'text-align-center' => TRUE,
        'text-align-right' => TRUE,
        'text-align-justify' => TRUE,
    ];
    return [
        'sourceEditing' => [
            'plugins' => [
                'ckeditor5_sourceEditing',
            ],
            'text_editor_settings' => [],
            'expected_elements' => [],
            'expected_readable_string' => '',
        ],
        'imageResize' => [
            'plugins' => [
                'ckeditor5_imageResize',
            ],
            'text_editor_settings' => [],
            'expected_elements' => [],
            'expected_readable_string' => '',
        ],
        'language' => [
            'plugins' => [
                'ckeditor5_language',
            ],
            'text_editor_settings' => [],
            'expected_elements' => [
                'span' => [
                    'lang' => TRUE,
                    'dir' => TRUE,
                ],
            ],
            'expected_readable_string' => '<span lang dir>',
        ],
        'alignment and heading' => [
            'plugins' => [
                'ckeditor5_alignment',
                'ckeditor5_heading',
                'ckeditor5_paragraph',
            ],
            'text_editor_settings' => [
                'plugins' => [
                    'ckeditor5_heading' => Heading::DEFAULT_CONFIGURATION,
                ],
            ],
            'expected_elements' => [
                'p' => [
                    'class' => $text_align_classes,
                ],
                'h2' => [
                    'class' => $text_align_classes,
                ],
                'h3' => [
                    'class' => $text_align_classes,
                ],
                'h4' => [
                    'class' => $text_align_classes,
                ],
                'h5' => [
                    'class' => $text_align_classes,
                ],
                'h6' => [
                    'class' => $text_align_classes,
                ],
            ],
            'expected_readable_string' => '<p class="text-align-left text-align-center text-align-right text-align-justify"> <h2 class="text-align-left text-align-center text-align-right text-align-justify"> <h3 class="text-align-left text-align-center text-align-right text-align-justify"> <h4 class="text-align-left text-align-center text-align-right text-align-justify"> <h5 class="text-align-left text-align-center text-align-right text-align-justify"> <h6 class="text-align-left text-align-center text-align-right text-align-justify">',
        ],
        'alignment and heading, but all class values allowed for headings' => [
            'plugins' => [
                'ckeditor5_alignment',
                'ckeditor5_heading',
                'ckeditor5_paragraph',
                'ckeditor5_plugin_elements_test_headingsUseClassAnyValue',
            ],
            'text_editor_settings' => [
                'plugins' => [
                    'ckeditor5_heading' => Heading::DEFAULT_CONFIGURATION,
                ],
            ],
            'expected_elements' => [
                'p' => [
                    'class' => $text_align_classes,
                ],
                'h2' => [
                    'class' => TRUE,
                ],
                'h3' => [
                    'class' => TRUE,
                ],
                'h4' => [
                    'class' => TRUE,
                ],
                'h5' => [
                    'class' => TRUE,
                ],
                'h6' => [
                    'class' => TRUE,
                ],
                'h1' => [
                    'class' => TRUE,
                ],
            ],
            'expected_readable_string' => '<p class="text-align-left text-align-center text-align-right text-align-justify"> <h2 class> <h3 class> <h4 class> <h5 class> <h6 class> <h1 class>',
        ],
        'heading text container combo' => [
            'plugins' => [
                'ckeditor5_plugin_elements_test_headingCombo',
                'ckeditor5_paragraph',
            ],
            'text_editor_settings' => [
                'plugins' => [],
            ],
            'expected_elements' => [
                'p' => [
                    'data-everytextcontainer' => TRUE,
                ],
                'h1' => [
                    'data-justheading' => TRUE,
                    'data-everytextcontainer' => TRUE,
                ],
            ],
            'expected_readable_string' => '<p data-everytextcontainer> <h1 data-justheading data-everytextcontainer>',
        ],
        'headings plus headings with attributes' => [
            'plugins' => [
                'ckeditor5_plugin_elements_test_headingsWithOtherAttributes',
                'ckeditor5_heading',
            ],
            'text_editor_settings' => [
                'plugins' => [
                    'ckeditor5_heading' => Heading::DEFAULT_CONFIGURATION,
                ],
            ],
            'expected_elements' => [
                'h2' => [
                    'class' => [
                        'additional-allowed-class' => TRUE,
                    ],
                ],
                'h3' => [
                    'data-just-h3' => TRUE,
                    'data-just-h3-limited' => [
                        'i-am-the-only-allowed-value' => TRUE,
                    ],
                ],
                'h4' => FALSE,
                'h5' => [
                    'data-just-h5-limited' => [
                        'first-allowed-value' => TRUE,
                        'second-allowed-value' => TRUE,
                    ],
                ],
                'h6' => FALSE,
                'h1' => [
                    'data-just-h1' => TRUE,
                ],
            ],
            'expected_readable_string' => '<h2 class="additional-allowed-class"> <h3 data-just-h3 data-just-h3-limited="i-am-the-only-allowed-value"> <h4> <h5 data-just-h5-limited="first-allowed-value second-allowed-value"> <h6> <h1 data-just-h1>',
        ],
        'headings plus headings with attributes and alignment' => [
            'plugins' => [
                'ckeditor5_plugin_elements_test_headingsWithOtherAttributes',
                'ckeditor5_heading',
                'ckeditor5_alignment',
            ],
            'text_editor_settings' => [
                'plugins' => [
                    'ckeditor5_heading' => Heading::DEFAULT_CONFIGURATION,
                ],
            ],
            'expected_elements' => [
                'h2' => [
                    'class' => [
                        'additional-allowed-class' => TRUE,
                    ] + $text_align_classes,
                ],
                'h3' => [
                    'data-just-h3' => TRUE,
                    'data-just-h3-limited' => [
                        'i-am-the-only-allowed-value' => TRUE,
                    ],
                    'class' => $text_align_classes,
                ],
                'h4' => [
                    'class' => $text_align_classes,
                ],
                'h5' => [
                    'data-just-h5-limited' => [
                        'first-allowed-value' => TRUE,
                        'second-allowed-value' => TRUE,
                    ],
                    'class' => $text_align_classes,
                ],
                'h6' => [
                    'class' => $text_align_classes,
                ],
                'h1' => [
                    'data-just-h1' => TRUE,
                    'class' => $text_align_classes,
                ],
            ],
            'expected_readable_string' => '<h2 class="additional-allowed-class text-align-left text-align-center text-align-right text-align-justify"> <h3 data-just-h3 data-just-h3-limited="i-am-the-only-allowed-value" class="text-align-left text-align-center text-align-right text-align-justify"> <h4 class="text-align-left text-align-center text-align-right text-align-justify"> <h5 data-just-h5-limited="first-allowed-value second-allowed-value" class="text-align-left text-align-center text-align-right text-align-justify"> <h6 class="text-align-left text-align-center text-align-right text-align-justify"> <h1 data-just-h1 class="text-align-left text-align-center text-align-right text-align-justify">',
        ],
    ];
}

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