function ValidatorsTest::provider
Same name in other branches
- 9 core/modules/ckeditor5/tests/src/Kernel/ValidatorsTest.php \Drupal\Tests\ckeditor5\Kernel\ValidatorsTest::provider()
- 10 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 114
Class
- ValidatorsTest
- @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator @covers…
Namespace
Drupal\Tests\ckeditor5\KernelCode
public static function provider() : array {
$data = [];
$data['CKEditor5::getDefaultSettings()'] = [
// @see ::test()
'ckeditor5_settings' => [
'__DEFAULT__',
],
'expected_violations' => [],
];
$data['non-existent toolbar button'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'underline',
'bold',
'italic',
'-',
'bulletedList',
'foobar',
],
],
'plugins' => [
'ckeditor5_list' => [
'properties' => [
'reversed' => FALSE,
'startIndex' => FALSE,
],
'multiBlock' => TRUE,
],
],
],
'expected_violations' => [
'settings.toolbar.items.5' => 'The provided toolbar item <em class="placeholder">foobar</em> is not valid.',
],
];
$data['missing heading plugin configuration'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'heading',
],
],
'plugins' => [],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'textPartLanguage',
],
],
'plugins' => [],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'textPartLanguage',
],
],
'plugins' => [
'ckeditor5_language' => [],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_language' => [
'Configuration for the enabled plugin "<em class="placeholder">Language</em>" (<em class="placeholder">ckeditor5_language</em>) is missing.',
"'language_list' is a required key because settings.plugins.%key is ckeditor5_language (see config schema type ckeditor5.plugin.ckeditor5_language).",
],
],
];
$data['valid language plugin configuration: un'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'textPartLanguage',
],
],
'plugins' => [
'ckeditor5_language' => [
'language_list' => 'un',
],
],
],
'expected_violations' => [],
];
$data['valid language plugin configuration: all'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'textPartLanguage',
],
],
'plugins' => [
'ckeditor5_language' => [
'language_list' => 'all',
],
],
],
'expected_violations' => [],
];
$data['invalid language plugin configuration: textPartLanguage button not enabled'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'bold',
],
],
'plugins' => [
'ckeditor5_language' => [
'language_list' => 'all',
],
],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'textPartLanguage',
],
],
'plugins' => [
'ckeditor5_language' => [
'language_list' => 'foo',
],
],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'drupalMedia',
],
],
'plugins' => [],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'fooBarConditions',
],
],
'plugins' => [],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'fooBarConditions',
'heading',
],
],
'plugins' => [
'ckeditor5_heading' => [
'enabled_headings' => [
'heading2',
],
],
],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'fooBarConditions',
'heading',
'insertTable',
],
],
'plugins' => [
'ckeditor5_heading' => [
'enabled_headings' => [
'heading2',
],
],
],
],
'expected_violations' => [],
];
$data['INVALID: Style plugin with no styles'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
],
],
'plugins' => [
'ckeditor5_style' => [
'styles' => [],
],
],
],
'expected_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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
'sourceEditing',
],
],
'plugins' => [
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<foo>',
],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Barry foo',
'element' => '<foo class="bar">',
],
],
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_style.styles.0.element' => 'A style can only be specified for an HTML 5 tag. <code><foo></code> is not an HTML5 tag.',
],
];
$data['INVALID: Style plugin configured to add class to plugin-supported non-HTML5 tag'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
],
],
'plugins' => [
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Sensational media',
'element' => '<drupal-media class="sensational">',
],
],
],
'media_media' => [
'allow_view_mode_override' => FALSE,
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_style.styles.0.element' => 'A style can only be specified for an HTML 5 tag. <code><drupal-media></code> is not an HTML5 tag.',
],
];
$data['INVALID: Style plugin configured to add class that is supported by a disabled plugin'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
],
],
'plugins' => [
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Justified paragraph',
'element' => '<p class="text-align-justify">',
],
],
],
],
],
'expected_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><p></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'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
'alignment',
],
],
'plugins' => [
'ckeditor5_alignment' => [
'enabled_alignments' => [
'center',
],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Justified paragraph',
'element' => '<p class="text-align-justify">',
],
],
],
],
],
'expected_violations' => [],
];
$data['INVALID: Style plugin configured to add class that is supported by an enabled plugin'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'style',
'alignment',
],
],
'plugins' => [
'ckeditor5_alignment' => [
'enabled_alignments' => [
'justify',
],
],
'ckeditor5_style' => [
'styles' => [
[
'label' => 'Justified paragraph',
'element' => '<p class="text-align-justify">',
],
],
],
],
],
'expected_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><p></code> are already supported by the enabled <em class="placeholder">Alignment</em> plugin.',
],
];
$data['INVALID: Style plugin configured to add class to plugin-supported tag known to not work with Style … yet'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'drupalInsertImage',
'style',
],
],
'plugins' => [
'ckeditor5_imageResize' => [
'allow_resize' => FALSE,
],
'ckeditor5_style' => [
'styles' => [
// @see https://github.com/ckeditor/ckeditor5/issues/13778
[
'label' => 'Featured image',
'element' => '<img class="featured">',
],
// @see https://www.drupal.org/project/drupal/issues/3398223
// @see https://github.com/ckeditor/ckeditor5/blob/39ad30090ead9dd2d54c3ac53d7f446ade9fd8ce/packages/ckeditor5-html-support/src/schemadefinitions.ts#L12-L50
[
'label' => 'Fancy linebreak',
'element' => '<br class="fancy">',
],
],
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_style.styles.0.element' => 'The <code><img></code> tag is not yet supported by the Style plugin.',
'settings.plugins.ckeditor5_style.styles.1.element' => 'The <code><br></code> tag is not yet supported by the Style plugin.',
],
];
$data['INVALID: Style plugin has multiple styles with same label'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'blockQuote',
'style',
],
],
'plugins' => [
'ckeditor5_style' => [
'styles' => [
0 => [
'label' => 'Highlighted',
'element' => '<p class="highlighted">',
],
1 => [
'label' => 'Highlighted',
'element' => '<blockquote class="highlighted">',
],
],
],
],
],
'expected_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'] = [
'ckeditor5_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="">',
],
],
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_style.styles.0.element' => 'The following tag is missing the required attribute <code>class</code>: <code><p></code>.',
'settings.plugins.ckeditor5_style.styles.1.element' => [
'The following tag is not valid HTML: <em class="placeholder"><blockquote class=""></em>.',
'The following tag does not have the minimum of 1 allowed values for the required attribute <code>class</code>: <code><blockquote class=""></code>.',
],
],
];
$data['VALID: Style plugin has multiple styles with different labels'] = [
'ckeditor5_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">',
],
],
],
],
],
'expected_violations' => [],
];
$data['INVALID: SourceEditing plugin configuration: <ol start type> must not be allowed because List can generate <ol reversed start>'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'numberedList',
'sourceEditing',
],
],
'plugins' => [
'ckeditor5_list' => [
'properties' => [
'reversed' => TRUE,
'startIndex' => TRUE,
],
'multiBlock' => TRUE,
],
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<ol start type>',
],
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_sourceEditing.allowed_tags.0' => 'The following attribute(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: <em class="placeholder">List (<ol start>)</em>.',
],
];
$data['INVALID: SourceEditing plugin configuration: <ol start type> must not be allowed because List can generate <ol start>'] = [
'ckeditor5_settings' => [
'toolbar' => [
'items' => [
'numberedList',
'sourceEditing',
],
],
'plugins' => [
'ckeditor5_list' => [
'properties' => [
'reversed' => FALSE,
'startIndex' => FALSE,
],
'multiBlock' => TRUE,
],
'ckeditor5_sourceEditing' => [
'allowed_tags' => [
'<ol start type>',
],
],
],
],
'expected_violations' => [
'settings.plugins.ckeditor5_sourceEditing.allowed_tags.0' => 'The following attribute(s) can optionally be supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: <em class="placeholder">List (<ol start>)</em>.',
],
];
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.