function ValidatorsTest::provider

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

Provides a list of Text Editor config entities using CKEditor 5 to test.

File

core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php, line 118

Class

ValidatorsTest
@covers <a href="/api/drupal/core%21modules%21ckeditor5%21src%21Plugin%21Validation%21Constraint%21ToolbarItemConstraintValidator.php/class/ToolbarItemConstraintValidator/9" title="Toolbar item constraint validator." class="local">\Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator</a> @covers <a href="/api/drupal/core%21modules%21ckeditor5%21src%21Plugin%21Validation%21Constraint%21ToolbarItemDependencyConstraintValidator.php/class/ToolbarItemDependencyConstraintValidator/9" title="Toolbar item dependency constraint validator." class="local">\Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator</a> @covers…

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function provider() : array {
    $data = [];
    $data['CKEditor5::getDefaultSettings()'] = [
        // @see ::test()
'settings' => [
            '__DEFAULT__',
        ],
        'violations' => [],
    ];
    $data['non-existent toolbar button'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'underline',
                    'bold',
                    'italic',
                    '-',
                    'bulletedList',
                    'foobar',
                ],
            ],
            'plugins' => [
                'ckeditor5_list' => [
                    'reversed' => FALSE,
                    'startIndex' => FALSE,
                ],
            ],
        ],
        'violations' => [
            'settings.toolbar.items.5' => 'The provided toolbar item <em class="placeholder">foobar</em> is not valid.',
        ],
    ];
    $data['missing heading plugin configuration'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'heading',
                ],
            ],
            'plugins' => [],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_heading' => 'Configuration for the enabled plugin "<em class="placeholder">Headings</em>" (<em class="placeholder">ckeditor5_heading</em>) is missing.',
        ],
    ];
    $data['missing language plugin configuration'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'textPartLanguage',
                ],
            ],
            'plugins' => [],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_language' => 'Configuration for the enabled plugin "<em class="placeholder">Language</em>" (<em class="placeholder">ckeditor5_language</em>) is missing.',
        ],
    ];
    $data['empty language plugin configuration'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'textPartLanguage',
                ],
            ],
            'plugins' => [
                'ckeditor5_language' => [],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_language' => 'Configuration for the enabled plugin "<em class="placeholder">Language</em>" (<em class="placeholder">ckeditor5_language</em>) is missing.',
        ],
    ];
    $data['valid language plugin configuration: un'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'textPartLanguage',
                ],
            ],
            'plugins' => [
                'ckeditor5_language' => [
                    'language_list' => 'un',
                ],
            ],
        ],
        'violations' => [],
    ];
    $data['valid language plugin configuration: all'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'textPartLanguage',
                ],
            ],
            'plugins' => [
                'ckeditor5_language' => [
                    'language_list' => 'all',
                ],
            ],
        ],
        'violations' => [],
    ];
    $data['invalid language plugin configuration: textPartLanguage button not enabled'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'bold',
                ],
            ],
            'plugins' => [
                'ckeditor5_language' => [
                    'language_list' => 'all',
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_language.language_list' => 'Depends on <em class="placeholder">textPartLanguage</em>, which is not enabled.',
        ],
    ];
    $data['invalid language plugin configuration: invalid language_list setting'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'textPartLanguage',
                ],
            ],
            'plugins' => [
                'ckeditor5_language' => [
                    'language_list' => 'foo',
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_language.language_list' => 'The value you selected is not a valid choice.',
        ],
    ];
    $data['drupalMedia toolbar item condition not met: media filter enabled'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'drupalMedia',
                ],
            ],
            'plugins' => [],
        ],
        'violations' => [
            'settings.toolbar.items.0' => 'The <em class="placeholder">Drupal media</em> toolbar item requires the <em class="placeholder">Embed media</em> filter to be enabled.',
        ],
    ];
    $data['fooBarConditions toolbar item condition not met: Heading and Table plugins enabled, neither are'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'fooBarConditions',
                ],
            ],
            'plugins' => [],
        ],
        'violations' => [
            'settings.toolbar.items.0' => 'The <em class="placeholder">Foo Bar (Test Plugins Condition)</em> toolbar item requires the <em class="placeholder">Headings, Table</em> plugins to be enabled.',
        ],
    ];
    $data['fooBarConditions toolbar item condition not met: Heading and Table plugins enabled, only one is'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'fooBarConditions',
                    'heading',
                ],
            ],
            'plugins' => [
                'ckeditor5_heading' => [
                    'enabled_headings' => [
                        'heading2',
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.toolbar.items.0' => 'The <em class="placeholder">Foo Bar (Test Plugins Condition)</em> toolbar item requires the <em class="placeholder">Table</em> plugin to be enabled.',
        ],
    ];
    $data['fooBarConditions toolbar item condition met: Heading and Table plugins enabled, both are'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'fooBarConditions',
                    'heading',
                    'insertTable',
                ],
            ],
            'plugins' => [
                'ckeditor5_heading' => [
                    'enabled_headings' => [
                        'heading2',
                    ],
                ],
            ],
        ],
        'violations' => [],
    ];
    $data['INVALID: Style plugin with no styles'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles' => 'Enable at least one style, otherwise disable the Style plugin.',
        ],
    ];
    $data['INVALID: Style plugin configured to add class to GHS-supported non-HTML5 tag'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                    'sourceEditing',
                ],
            ],
            'plugins' => [
                'ckeditor5_sourceEditing' => [
                    'allowed_tags' => [
                        '<foo>',
                    ],
                ],
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Barry foo',
                            'element' => '<foo class="bar">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles.0.element' => 'A style can only be specified for an HTML 5 tag. <code>&lt;foo&gt;</code> is not an HTML5 tag.',
        ],
    ];
    $data['INVALID: Style plugin configured to add class to plugin-supported non-HTML5 tag'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Sensational media',
                            'element' => '<drupal-media class="sensational">',
                        ],
                    ],
                ],
                'media_media' => [
                    'allow_view_mode_override' => FALSE,
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles.0.element' => 'A style can only be specified for an HTML 5 tag. <code>&lt;drupal-media&gt;</code> is not an HTML5 tag.',
        ],
    ];
    $data['INVALID: Style plugin configured to add class that is supported by a disabled plugin'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Justified paragraph',
                            'element' => '<p class="text-align-justify">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles.0.element' => 'A style must only specify classes not supported by other plugins. The <code>text-align-justify</code> classes on <code>&lt;p&gt;</code> are supported by the <em class="placeholder">Alignment</em> plugin. Remove this style and enable that plugin instead.',
        ],
    ];
    $data['INVALID: Style plugin configured to add class that is supported by an enabled plugin if its configuration were different'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                    'alignment',
                ],
            ],
            'plugins' => [
                'ckeditor5_alignment' => [
                    'enabled_alignments' => [
                        'center',
                    ],
                ],
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Justified paragraph',
                            'element' => '<p class="text-align-justify">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [],
    ];
    $data['INVALID: Style plugin configured to add class that is supported by an enabled plugin'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'style',
                    'alignment',
                ],
            ],
            'plugins' => [
                'ckeditor5_alignment' => [
                    'enabled_alignments' => [
                        'justify',
                    ],
                ],
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Justified paragraph',
                            'element' => '<p class="text-align-justify">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles.0.element' => 'A style must only specify classes not supported by other plugins. The <code>text-align-justify</code> classes on <code>&lt;p&gt;</code> are already supported by the enabled <em class="placeholder">Alignment</em> plugin.',
        ],
    ];
    $data['INVALID: Style plugin has multiple styles with same label'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'blockQuote',
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [
                        0 => [
                            'label' => 'Highlighted',
                            'element' => '<p class="highlighted">',
                        ],
                        1 => [
                            'label' => 'Highlighted',
                            'element' => '<blockquote class="highlighted">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles' => 'The label <em class="placeholder">Highlighted</em> is not unique.',
        ],
    ];
    $data['INVALID: Style plugin has styles with invalid elements'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'blockQuote',
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [
                        0 => [
                            'label' => 'missing class attribute',
                            'element' => '<p>',
                        ],
                        1 => [
                            'label' => 'class attribute present but no allowed values listed',
                            'element' => '<blockquote class="">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [
            'settings.plugins.ckeditor5_style.styles.0.element' => 'The following tag is missing the required attribute <code>class</code>: <code>&lt;p&gt;</code>.',
            'settings.plugins.ckeditor5_style.styles.1.element' => 'The following tag does not have the minimum of 1 allowed values for the required attribute <code>class</code>: <code>&lt;blockquote class=&quot;&quot;&gt;</code>.',
        ],
    ];
    $data['VALID: Style plugin has multiple styles with different labels'] = [
        'settings' => [
            'toolbar' => [
                'items' => [
                    'blockQuote',
                    'style',
                ],
            ],
            'plugins' => [
                'ckeditor5_style' => [
                    'styles' => [
                        [
                            'label' => 'Callout',
                            'element' => '<p class="callout">',
                        ],
                        [
                            'label' => 'Interesting & highlighted quote',
                            'element' => '<blockquote class="interesting highlighted">',
                        ],
                        [
                            'label' => 'Famous',
                            'element' => '<blockquote class="famous">',
                        ],
                    ],
                ],
            ],
        ],
        'violations' => [],
    ];
    return $data;
}

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