class ValidatorsTest

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

@covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\EnabledConfigurablePluginsConstraintValidator @covers \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair() @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\CKEditor5MediaAndFilterSettingsInSyncConstraintValidator @group ckeditor5

Hierarchy

Expanded class hierarchy of ValidatorsTest

File

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

Namespace

Drupal\Tests\ckeditor5\Kernel
View source
class ValidatorsTest extends KernelTestBase {
    use SchemaCheckTestTrait;
    use CKEditor5ValidationTestTrait;
    
    /**
     * The typed config manager.
     *
     * @var \Drupal\Core\Config\TypedConfigManagerInterface
     */
    protected $typedConfig;
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'ckeditor5',
        'ckeditor5_plugin_conditions_test',
        'editor',
        'filter',
        'media',
        'media_library',
        'views',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->typedConfig = $this->container
            ->get('config.typed');
    }
    
    /**
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\EnabledConfigurablePluginsConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\CKEditor5ElementConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\StyleSensibleElementConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\UniqueLabelInListConstraintValidator
     * @dataProvider provider
     *
     * @param array $ckeditor5_settings
     *   The CKEditor 5 settings to test.
     * @param array $expected_violations
     *   All expected violations for the given CKEditor 5 settings, with property
     *   path as keys and message as values.
     */
    public function test(array $ckeditor5_settings, array $expected_violations) {
        // The data provider is unable to access services, so the test scenario of
        // testing with CKEditor 5's default settings is partially provided here.
        if ($ckeditor5_settings === [
            '__DEFAULT__',
        ]) {
            $ckeditor5_settings = \Drupal::service('plugin.manager.editor')->createInstance('ckeditor5')
                ->getDefaultSettings();
        }
        FilterFormat::create([
            'format' => 'dummy',
            'name' => 'Dummy',
        ])->save();
        $editor = Editor::create([
            'format' => 'dummy',
            'editor' => 'ckeditor5',
            'settings' => $ckeditor5_settings,
            'image_upload' => [],
        ]);
        $typed_config = $this->typedConfig
            ->createFromNameAndData($editor->getConfigDependencyName(), $editor->toArray());
        $violations = $typed_config->validate();
        $actual_violations = [];
        foreach ($violations as $violation) {
            $actual_violations[$violation->getPropertyPath()] = (string) $violation->getMessage();
        }
        $this->assertSame($expected_violations, $actual_violations);
        if (empty($expected_violations)) {
            $this->assertConfigSchema($this->typedConfig, $editor->getConfigDependencyName(), $typed_config->getValue());
        }
    }
    
    /**
     * Provides a list of Text Editor config entities using CKEditor 5 to test.
     */
    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;
    }
    
    /**
     * @covers \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair()
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\EnabledConfigurablePluginsConstraintValidator
     * @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\SourceEditingPreventSelfXssConstraintValidator
     * @dataProvider providerPair
     *
     * @param array $ckeditor5_settings
     *   The paired text editor's CKEditor 5 settings to test.
     * @param array $editor_image_upload_settings
     *   The paired text editor's image upload settings to test.
     * @param array $filters
     *   The paired text format's filters and filter settings.
     * @param array $expected_violations
     *   All expected violations for the pair.
     */
    public function testPair(array $ckeditor5_settings, array $editor_image_upload_settings, array $filters, array $expected_violations) {
        $text_editor = Editor::create([
            'format' => 'dummy',
            'editor' => 'ckeditor5',
            'settings' => $ckeditor5_settings,
            'image_upload' => $editor_image_upload_settings,
        ]);
        EntityViewMode::create([
            'id' => 'media.view_mode_1',
            'targetEntityType' => 'media',
            'status' => TRUE,
            'enabled' => TRUE,
            'label' => 'View Mode 1',
        ])->save();
        EntityViewMode::create([
            'id' => 'media.view_mode_2',
            'targetEntityType' => 'media',
            'status' => TRUE,
            'enabled' => TRUE,
            'label' => 'View Mode 2',
        ])->save();
        assert($text_editor instanceof EditorInterface);
        $this->assertConfigSchema($this->typedConfig, $text_editor->getConfigDependencyName(), $text_editor->toArray());
        $text_format = FilterFormat::create([
            'filters' => $filters,
        ]);
        assert($text_format instanceof FilterFormatInterface);
        $this->assertSame($expected_violations, $this->validatePairToViolationsArray($text_editor, $text_format, TRUE));
    }
    
    /**
     * Provides a list of Text Editor + Text Format pairs to test.
     */
    public function providerPair() : array {
        // cspell:ignore donk
        $data = [];
        $data['INVALID: allow_view_mode_override condition not met: filter must be configured to allow 2 or more view modes'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [
                    'media_media' => [
                        'allow_view_mode_override' => TRUE,
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'media_embed' => [
                    'id' => 'media_embed',
                    'provider' => 'media',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'default_view_mode' => 'default',
                        'allowed_view_modes' => [],
                        'allowed_media_types' => [],
                    ],
                ],
            ],
            'violations' => [
                '' => 'The CKEditor 5 "<em class="placeholder">Media</em>" plugin\'s "<em class="placeholder">Allow the user to override the default view mode</em>" setting should be in sync with the "<em class="placeholder">Embed media</em>" filter\'s "<em class="placeholder">View modes selectable in the &quot;Edit media&quot; dialog</em>" setting: when checked, two or more view modes must be allowed by the filter.',
            ],
        ];
        $data['VALID: allow_view_mode_override condition met: filter must be configured to allow 2 or more view modes'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalMedia',
                    ],
                ],
                'plugins' => [
                    'media_media' => [
                        'allow_view_mode_override' => TRUE,
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'media_embed' => [
                    'id' => 'media_embed',
                    'provider' => 'media',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'default_view_mode' => 'view_mode_1',
                        'allowed_view_modes' => [
                            'view_mode_1' => 'view_mode_1',
                            'view_mode_2' => 'view_mode_2',
                        ],
                        'allowed_media_types' => [],
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: legacy format: filter_autop'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'bold',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_autop' => [
                    'id' => 'filter_autop',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: legacy HTML format: filter_autop + filter_url'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'bold',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_autop' => [
                    'id' => 'filter_autop',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [],
                ],
                'filter_url' => [
                    'id' => 'filter_url',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => -10,
                    'settings' => [
                        'filter_url_length' => 72,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: legacy HTML format: filter_autop + filter_url (different order)'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'bold',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_autop' => [
                    'id' => 'filter_autop',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [],
                ],
                'filter_url' => [
                    'id' => 'filter_url',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 10,
                    'settings' => [
                        'filter_url_length' => 72,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $restricted_html_format_filters = Yaml::parseFile(__DIR__ . '/../../../../../profiles/standard/config/install/filter.format.restricted_html.yml')['filters'];
        $data['INVALID: the default restricted_html text format'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => $restricted_html_format_filters,
            'violations' => [
                '' => 'CKEditor 5 needs at least the &lt;p&gt; and &lt;br&gt; tags to be allowed to be able to function. They are not allowed by the "<em class="placeholder">Limit allowed HTML tags and correct faulty HTML</em>" (<em class="placeholder">filter_html</em>) filter.',
            ],
        ];
        $data['INVALID: the modified restricted_html text format (with filter_autop and filter_url removed)'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => array_diff_key($restricted_html_format_filters, [
                'filter_autop' => TRUE,
                'filter_url' => TRUE,
            ]),
            'violations' => [
                '' => 'CKEditor 5 needs at least the &lt;p&gt; and &lt;br&gt; tags to be allowed to be able to function. They are not allowed by the "<em class="placeholder">Limit allowed HTML tags and correct faulty HTML</em>" (<em class="placeholder">filter_html</em>) filter.',
            ],
        ];
        $data['VALID: HTML format: empty toolbar + minimal allowed HTML'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => "<p> <br>",
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: HTML format: very minimal toolbar + minimal allowed HTML'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'bold',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => "<p> <br> <strong>",
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['INVALID: HTML format: empty toolbar + default allowed HTML tags + <p> + <br>'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>" . "<p> <br>",
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [
                'filters.filter_html' => sprintf('The current CKEditor 5 build requires the following elements and attributes: <br><code>%s</code><br>The following elements are not supported: <br><code>%s</code>', Html::escape('<br> <p> <* dir="ltr rtl" lang>'), Html::escape('<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type="1 A I"> <li> <dl> <dt> <dd> <h2 id="jump-*"> <h3 id> <h4 id> <h5 id> <h6 id>')),
            ],
        ];
        $data['INVALID: HTML format: empty toolbar + default allowed HTML tags'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => "<a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>",
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [
                '' => 'CKEditor 5 needs at least the &lt;p&gt; and &lt;br&gt; tags to be allowed to be able to function. They are not allowed by the "<em class="placeholder">Limit allowed HTML tags and correct faulty HTML</em>" (<em class="placeholder">filter_html</em>) filter.',
            ],
        ];
        $data['INVALID Source Editable tag already provided by plugin and another available in a not enabled plugin'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'heading',
                        'bold',
                        'italic',
                        'link',
                        'sourceEditing',
                        'textPartLanguage',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_heading' => [
                        'enabled_headings' => [
                            'heading2',
                            'heading3',
                            'heading4',
                            'heading5',
                            'heading6',
                        ],
                    ],
                    'ckeditor5_language' => [
                        'language_list' => 'un',
                    ],
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => [
                            // Tag-only; supported by enabled plugin.
'<strong>',
                            // Tag-only; supported by disabled plugin.
'<table>',
                            // Tag-only; supported by no plugin.
'<exotic>',
                            // Tag + attributes; all supported by enabled plugin.
'<span lang>',
                            // Tag + attributes; all supported by an ineligible disabled
                            // plugin (has no toolbar item, has conditions).
'<img src>',
                            // Tag + attributes; attributes supported by disabled plugin.
'<code class="language-*">',
                            // Tag + attributes; tag already supported by enabled plugin,
                            // attributes supported by disabled plugin
'<h2 class="text-align-center">',
                            // Tag + attributes; tag already supported by enabled plugin,
                            // attribute not supported by no plugin.
'<a hreflang>',
                            // Tag-only; supported by no plugin (only attributes on tag
                            // supported by a plugin).
'<span>',
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => TRUE,
            ],
            'filters' => [],
            'violations' => [
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.0' => 'The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: <em class="placeholder">Bold (&lt;strong&gt;)</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.1' => 'The following tag(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these tags: <em class="placeholder">Table (&lt;table&gt;)</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.3' => '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">Language (&lt;span lang&gt;)</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.5' => 'The following attribute(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these attributes: <em class="placeholder">Code Block (&lt;code class=&quot;language-*&quot;&gt;)</em>.',
                // @todo "Style" should be removed from the suggestions in https://www.drupal.org/project/drupal/issues/3271179
'settings.plugins.ckeditor5_sourceEditing.allowed_tags.6' => 'The following attribute(s) are already supported by available plugins and should not be added to the Source Editing "Manually editable HTML tags" field. Instead, enable the following plugins to support these attributes: <em class="placeholder">Style (&lt;h2 class=&quot;text-align-center&quot;&gt;), Alignment (&lt;h2 class=&quot;text-align-center&quot;&gt;)</em>.',
            ],
        ];
        $data['INVALID some invalid Source Editable tags provided by plugin and another available in a not enabled plugin'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'heading',
                        'bold',
                        'italic',
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_heading' => [
                        'enabled_headings' => [
                            'heading2',
                            'heading3',
                            'heading4',
                            'heading5',
                            'heading6',
                        ],
                    ],
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => [
                            '<aside>',
                            '<footer>',
                            'roy',
                            '<#donk>',
                            '<junior>cruft',
                            '',
                            '   ',
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => TRUE,
            ],
            'filters' => [],
            'violations' => [
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.2' => 'The following tag is not valid HTML: <em class="placeholder">roy</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.3' => 'The following tag is not valid HTML: <em class="placeholder">&lt;#donk&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.4' => 'The following tag is not valid HTML: <em class="placeholder">&lt;junior&gt;cruft</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.5' => 'The following tag is not valid HTML: <em class="placeholder"></em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.6' => 'The following tag is not valid HTML: <em class="placeholder">   </em>.',
            ],
        ];
        $data['INVALID: drupalInsertImage without required dependent plugin configuration'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalInsertImage',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [],
            'violations' => [
                'settings.plugins.ckeditor5_imageResize' => 'Configuration for the enabled plugin "<em class="placeholder">Image resize</em>" (<em class="placeholder">ckeditor5_imageResize</em>) is missing.',
            ],
        ];
        $data['VALID: drupalInsertImage toolbar item without image upload'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalInsertImage',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_imageResize' => [
                        'allow_resize' => FALSE,
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [],
            'violations' => [],
        ];
        $data['VALID: drupalInsertImage image upload enabled'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalInsertImage',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_imageResize' => [
                        'allow_resize' => FALSE,
                    ],
                ],
            ],
            'image' => [
                'status' => TRUE,
            ],
            'filters' => [],
            'violations' => [],
        ];
        $data['INVALID: drupalMedia toolbar item condition NOT met: media filter enabled'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalMedia',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [],
            '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['VALID: drupalMedia toolbar item condition met: media filter enabled'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'drupalMedia',
                    ],
                ],
                'plugins' => [],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'media_embed',
                    'provider' => 'media',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'default_view_mode' => 'default',
                        'allowed_view_modes' => [],
                        'allowed_media_types' => [],
                    ],
                ],
            ],
            '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['VALID: HTML format: very minimal toolbar + wildcard in source editing HTML'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'bold',
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => [
                            '<$text-container data-llama>',
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p data-llama> <br> <strong>',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $self_xss_source_editing = [
            // Dangerous attribute with all values allowed.
'<p onhover>',
            '<img on*>',
            '<blockquote style>',
            // No danger.
'<marquee>',
            // Dangerous attribute with some values allowed.
'<a onclick="javascript:*">',
            '<code style="foo: bar;">',
            // Also works on wildcard tags.
'<$text-container style>',
        ];
        $data['INVALID: SourceEditing plugin configuration: self-XSS detected when using filter_html'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => $self_xss_source_editing,
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p onhover style> <br> <img on*> <blockquote style> <marquee> <a onclick="javascript:*"> <code style="foo: bar;">',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [
                'filters.filter_html' => 'The current CKEditor 5 build requires the following elements and attributes: <br><code>&lt;br&gt; &lt;p onhover style&gt; &lt;* dir=&quot;ltr rtl&quot; lang&gt; &lt;img on*&gt; &lt;blockquote style&gt; &lt;marquee&gt; &lt;a onclick=&quot;javascript:*&quot;&gt; &lt;code style=&quot;foo: bar;&quot;&gt;</code><br>The following elements are missing: <br><code>&lt;p onhover style&gt; &lt;img on*&gt; &lt;blockquote style&gt; &lt;code style=&quot;foo: bar;&quot;&gt;</code>',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.0' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;p onhover&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.1' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;img on*&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.2' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;blockquote style&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.4' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;a onclick=&quot;javascript:*&quot;&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.5' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;code style=&quot;foo: bar;&quot;&gt;</em>.',
                'settings.plugins.ckeditor5_sourceEditing.allowed_tags.6' => 'The following tag in the Source Editing "Manually editable HTML tags" field is a security risk: <em class="placeholder">&lt;$text-container style&gt;</em>.',
            ],
        ];
        $data['VALID: SourceEditing plugin configuration: self-XSS not detected when not using filter_html'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => $self_xss_source_editing,
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [],
            'violations' => [],
        ];
        $data['INVALID: Style plugin configured to add class to unsupported tag'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'style',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Highlighted',
                                'element' => '<blockquote class="highlighted">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p> <br> <blockquote class="highlighted">',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [
                'settings.plugins.ckeditor5_style' => 'The <em class="placeholder">Style</em> plugin needs another plugin to create <code>&lt;blockquote&gt;</code>, for it to be able to create the following attributes: <code>&lt;blockquote class=&quot;highlighted&quot;&gt;</code>. Enable a plugin that supports creating this tag. If none exists, you can configure the Source Editing plugin to support it.',
            ],
        ];
        $data['INVALID: Style plugin configured to add class already added by an other plugin'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'alignment',
                        'style',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_alignment' => [
                        'enabled_alignments' => [
                            'justify',
                        ],
                    ],
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Text align',
                                'element' => '<p class="text-align-justify">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p class="text-align-justify"> <br>',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            '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['VALID: Style plugin configured to add new class to an already restricted tag'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'alignment',
                        'style',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_alignment' => [
                        'enabled_alignments' => [
                            'justify',
                        ],
                    ],
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Add baguette class',
                                'element' => '<p class="baguette">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p class="text-align-justify baguette"> <br>',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: Style plugin configured to add class to an element provided by an explicit plugin that already allows all classes'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'kbdAllClasses',
                        'style',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Add baguette class',
                                'element' => '<kbd class="baguette">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p> <br> <kbd class>',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: Style plugin configured to add class to GHS-supported HTML5 tag'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'style',
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => [
                            '<kbd>',
                        ],
                    ],
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Add baguette class',
                                'element' => '<kbd class="baguette">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p> <br> <kbd class="baguette">',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        $data['VALID: Style plugin configured to add class to GHS-supported HTML5 tag that already allows all classes'] = [
            'settings' => [
                'toolbar' => [
                    'items' => [
                        'style',
                        'sourceEditing',
                    ],
                ],
                'plugins' => [
                    'ckeditor5_sourceEditing' => [
                        'allowed_tags' => [
                            '<bdi class>',
                        ],
                    ],
                    'ckeditor5_style' => [
                        'styles' => [
                            [
                                'label' => 'Bidirectional name',
                                'element' => '<bdi class="name">',
                            ],
                        ],
                    ],
                ],
            ],
            'image_upload' => [
                'status' => FALSE,
            ],
            'filters' => [
                'filter_html' => [
                    'id' => 'filter_html',
                    'provider' => 'filter',
                    'status' => TRUE,
                    'weight' => 0,
                    'settings' => [
                        'allowed_html' => '<p> <br> <bdi class>',
                        'filter_html_help' => TRUE,
                        'filter_html_nofollow' => TRUE,
                    ],
                ],
            ],
            'violations' => [],
        ];
        return $data;
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
AssertContentTrait::$content protected property The current raw content.
AssertContentTrait::$drupalSettings protected property The drupalSettings value from the current raw $content.
AssertContentTrait::$elements protected property The XML structure parsed from the current raw $content. 1
AssertContentTrait::$plainTextContent protected property The plain-text content of raw $content (text nodes).
AssertContentTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertContentTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertContentTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertContentTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertContentTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertContentTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertContentTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertContentTrait::assertLink protected function Passes if a link with the specified label is found.
AssertContentTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertContentTrait::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
AssertContentTrait::assertNoEscaped protected function Passes if raw text IS NOT found escaped on loaded page, fail otherwise.
AssertContentTrait::assertNoField protected function Asserts that a field does not exist with the given name or ID.
AssertContentTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertContentTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertContentTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertContentTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertContentTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertContentTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertContentTrait::assertNoLinkByHrefInMainRegion protected function Passes if a link containing a given href is not found in the main region.
AssertContentTrait::assertNoOption protected function Asserts that a select option in the current page does not exist.
AssertContentTrait::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
AssertContentTrait::assertNoPattern protected function Triggers a pass if the perl regex pattern is not found in raw content.
AssertContentTrait::assertNoRaw protected function Passes if the raw text is NOT found on the loaded page, fail otherwise.
AssertContentTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text.
AssertContentTrait::assertNoTitle protected function Pass if the page title is not the given string.
AssertContentTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertContentTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertContentTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionSelectedWithDrupalSelector protected function Asserts that a select option in the current page is checked.
AssertContentTrait::assertOptionWithDrupalSelector protected function Asserts that a select option in the current page exists.
AssertContentTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertContentTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise.
AssertContentTrait::assertText protected function Passes if the page (with HTML stripped) contains the text.
AssertContentTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertContentTrait::assertTextPattern protected function Asserts that a Perl regex pattern is found in the plain-text content.
AssertContentTrait::assertThemeOutput protected function Asserts themed output.
AssertContentTrait::assertTitle protected function Pass if the page title is the given string.
AssertContentTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertContentTrait::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
AssertContentTrait::buildXPathQuery protected function Builds an XPath query.
AssertContentTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertContentTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
AssertContentTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertContentTrait::getDrupalSettings protected function Gets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::getRawContent protected function Gets the current raw content.
AssertContentTrait::getSelectedItem protected function Get the selected value from a select field.
AssertContentTrait::getTextContent protected function Retrieves the plain-text content from the current raw content.
AssertContentTrait::getUrl protected function Get the current URL from the cURL handler. 1
AssertContentTrait::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
AssertContentTrait::removeWhiteSpace protected function Removes all white-space between HTML tags from the raw content.
AssertContentTrait::setDrupalSettings protected function Sets the value of drupalSettings for the currently-loaded page.
AssertContentTrait::setRawContent protected function Sets the raw content (e.g. HTML).
AssertContentTrait::xpath protected function Performs an xpath search on the contents of the internal browser.
AssertLegacyTrait::assert Deprecated protected function
AssertLegacyTrait::assertEqual Deprecated protected function
AssertLegacyTrait::assertIdentical Deprecated protected function
AssertLegacyTrait::assertIdenticalObject Deprecated protected function
AssertLegacyTrait::assertNotEqual Deprecated protected function
AssertLegacyTrait::assertNotIdentical Deprecated protected function
AssertLegacyTrait::pass Deprecated protected function
AssertLegacyTrait::verbose Deprecated protected function
CKEditor5ValidationTestTrait::validatePairToViolationsArray private function Decorator for CKEditor5::validatePair() that returns an assertable array.
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
KernelTestBase::$backupGlobals protected property Back up and restore any global variables that may be changed by tests.
KernelTestBase::$backupStaticAttributes protected property Back up and restore static class properties that may be changed by tests.
KernelTestBase::$backupStaticAttributesBlacklist protected property Contains a few static class properties for performance.
KernelTestBase::$classLoader protected property
KernelTestBase::$configImporter protected property @todo Move into Config test base class. 6
KernelTestBase::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
KernelTestBase::$container protected property
KernelTestBase::$databasePrefix protected property
KernelTestBase::$keyValue protected property The key_value service that must persist between container rebuilds.
KernelTestBase::$preserveGlobalState protected property Do not forward any global state from the parent process to the processes
that run the actual tests.
KernelTestBase::$root protected property The app root.
KernelTestBase::$runTestInSeparateProcess protected property Kernel tests are run in separate processes because they allow autoloading
of code from extensions. Running the test in a separate process isolates
this behavior from other tests. Subclasses should not override this
property.
KernelTestBase::$siteDirectory protected property
KernelTestBase::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 7
KernelTestBase::$vfsRoot protected property The virtual filesystem root directory.
KernelTestBase::assertPostConditions protected function 1
KernelTestBase::bootEnvironment protected function Bootstraps a basic test environment.
KernelTestBase::bootKernel private function Bootstraps a kernel for a test.
KernelTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
KernelTestBase::disableModules protected function Disables modules for this test.
KernelTestBase::enableModules protected function Enables modules for this test.
KernelTestBase::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
KernelTestBase::getDatabaseConnectionInfo protected function Returns the Database connection info to be used for this test. 3
KernelTestBase::getDatabasePrefix public function
KernelTestBase::getExtensionsForModules private function Returns Extension objects for $modules to enable.
KernelTestBase::getModulesToEnable private static function Returns the modules to enable for this test.
KernelTestBase::initFileCache protected function Initializes the FileCache component.
KernelTestBase::installConfig protected function Installs default configuration for a given list of modules.
KernelTestBase::installEntitySchema protected function Installs the storage schema for a specific entity type.
KernelTestBase::installSchema protected function Installs database tables from a module schema definition.
KernelTestBase::register public function Registers test-specific services. Overrides ServiceProviderInterface::register 26
KernelTestBase::render protected function Renders a render array. 1
KernelTestBase::setInstallProfile protected function Sets the install profile and rebuilds the container to update it.
KernelTestBase::setSetting protected function Sets an in-memory Settings variable.
KernelTestBase::setUpBeforeClass public static function 1
KernelTestBase::setUpFilesystem protected function Sets up the filesystem, so things like the file directory. 3
KernelTestBase::stop protected function Stops test execution.
KernelTestBase::tearDown protected function 5
KernelTestBase::tearDownCloseDatabaseConnection public function @after
KernelTestBase::vfsDump protected function Dumps the current state of the virtual filesystem to STDOUT.
KernelTestBase::__sleep public function Prevents serializing any properties.
PhpUnitWarnings::$deprecationWarnings private static property Deprecation warnings from PHPUnit to raise with @trigger_error().
PhpUnitWarnings::addWarning public function Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers. 1
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
SchemaCheckTestTrait::assertConfigSchema public function Asserts the TypedConfigManager has a valid schema for the configuration.
SchemaCheckTestTrait::assertConfigSchemaByName public function Asserts configuration, specified by name, has a valid schema.
SchemaCheckTrait::$configName protected property The configuration object name under test.
SchemaCheckTrait::$schema protected property The config schema wrapper object for the configuration object under test.
SchemaCheckTrait::checkConfigSchema public function Checks the TypedConfigManager has a valid schema for the configuration.
SchemaCheckTrait::checkValue protected function Helper method to check data type.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestRequirementsTrait::checkModuleRequirements private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements protected function Check module requirements for the Drupal use case.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
ValidatorsTest::$modules protected static property Modules to enable. Overrides KernelTestBase::$modules
ValidatorsTest::$typedConfig protected property The typed config manager.
ValidatorsTest::provider public function Provides a list of Text Editor config entities using CKEditor 5 to test.
ValidatorsTest::providerPair public function Provides a list of Text Editor + Text Format pairs to test.
ValidatorsTest::setUp protected function Overrides KernelTestBase::setUp
ValidatorsTest::test public function @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraintValidator
@covers \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemDependencyConstraintValidator
@covers…
ValidatorsTest::testPair public function @covers \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair()
@covers \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator
@covers…

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