function SmartDefaultSettingsTest::provider

Same name and namespace in other branches
  1. 10 core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider()
  2. 9 core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider()
  3. main core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php \Drupal\Tests\ckeditor5\Kernel\SmartDefaultSettingsTest::provider()

Data provider.

Return value

\Generator Test scenarios.

File

core/modules/ckeditor5/tests/src/Kernel/SmartDefaultSettingsTest.php, line 590

Class

SmartDefaultSettingsTest
Tests Smart Default Settings.

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public static function provider() {
  $basic_html_test_case = [
    'format_id' => 'basic_html',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          '|',
          // Items added based on "allowed tags" config.
'link',
          'blockQuote',
          'code',
          'bulletedList',
          'numberedList',
          'drupalInsertImage',
          // Because additional tags need to be allowed to achieve a superset.
'|',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_imageResize' => [
          'allow_resize' => TRUE,
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [
            '<cite>',
            '<dl>',
            '<dt>',
            '<dd>',
            '<span>',
            '<a hreflang>',
            '<blockquote cite>',
            '<h2 id>',
            '<h3 id>',
            '<h4 id>',
            '<h5 id>',
            '<h6 id>',
          ],
        ],
      ],
    ],
    'expected_superset' => '<ol reversed>',
    'expected_fundamental_compatibility_violations' => [],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:10:"Basic HTML";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:10:"Basic HTML";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
      ],
    ],
    'expected_messages' => [],
  ];
  yield "basic_html can be switched to CKEditor 5 without problems (3 upgrade messages)" => NestedArray::mergeDeep($basic_html_test_case, [
    'expected_db_logs' => [
      'status' => [
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:10:"Basic HTML";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ]);
  yield "basic_html with filter_caption removed => disallows <img data-caption> => supported through sourceEditing (3 upgrade messages)" => [
    'format_id' => 'basic_html',
    'filters_to_drop' => [
      'filter_caption' => FALSE,
    ],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 0, 7), [
            '<img data-caption>',
          ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 7)),
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        $basic_html_test_case['expected_db_logs']['status'],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:10:"Basic HTML";s:19:"@missing_attributes";s:89:"<a hreflang> <blockquote cite> <img data-caption> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;img data-caption&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html with filter_align removed => disallows <img data-align> => supported through sourceEditing (3 upgrade messages) " => [
    'format_id' => 'basic_html',
    'filters_to_drop' => [
      'filter_align' => FALSE,
    ],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 0, 7), [
            '<img data-align>',
          ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 7)),
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        $basic_html_test_case['expected_db_logs']['status'],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:10:"Basic HTML";s:19:"@missing_attributes";s:87:"<a hreflang> <blockquote cite> <img data-align> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;img data-align&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_without_image_uploads can be switched to CKEditor 5 without problems, <img data-entity-type data-entity-uuid> support is retained via sourceEditing" => [
    'format_id' => 'basic_html_without_image_uploads',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 0, 7), [
            '<img data-entity-type data-entity-uuid>',
          ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 7)),
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:34:"Basic HTML (without image uploads)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:34:"Basic HTML (without image uploads)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:34:"Basic HTML (without image uploads)";s:19:"@missing_attributes";s:110:"<a hreflang> <blockquote cite> <img data-entity-type data-entity-uuid> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;img data-entity-type data-entity-uuid&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_without_h4_h6 can be switched to CKEditor 5 without problems" => [
    'format_id' => 'basic_html_without_h4_h6',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_imageResize' => [
          'allow_resize' => TRUE,
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_values(array_diff($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], [
            '<h4 id>',
            '<h6 id>',
          ])),
        ],
      ],
    ],
    'expected_superset' => '<h4> <h6> ' . $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:30:"Basic HTML (without H4 and H6)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:30:"Basic HTML (without H4 and H6)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:30:"Basic HTML (without H4 and H6)";s:19:"@missing_attributes";s:54:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h5 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h5 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:  The tags <em class="placeholder">&lt;h4&gt;, &lt;h6&gt;</em>; This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_with_h1 can be switched to CKEditor 5 without problems" => [
    'format_id' => 'basic_html_with_h1',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_imageResize' => [
          'allow_resize' => TRUE,
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 0, 5), [
            '<h1>',
          ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 5)),
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:22:"Basic HTML (with <h1>)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:22:"Basic HTML (with <h1>)";s:19:"@unsupported_string";s:33:"<cite> <dl> <dt> <dd> <span> <h1>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:22:"Basic HTML (with <h1>)";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;h1&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_without_headings can be switched to CKEditor 5 without problems" => [
    'format_id' => 'basic_html_without_headings',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'],
      ],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => [
          'allow_resize' => TRUE,
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_values(array_diff($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], [
            '<h2 id>',
            '<h3 id>',
            '<h4 id>',
            '<h5 id>',
            '<h6 id>',
          ])),
        ],
      ],
    ],
    'expected_superset' => '<h2> <h3> <h4> <h5> <h6> ' . $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (without H*)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (without H*)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (without H*)";s:19:"@missing_attributes";s:30:"<a hreflang> <blockquote cite>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:  The tags <em class="placeholder">&lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;</em>; This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_with_pre can be switched to CKEditor 5 without problems" => [
    'format_id' => 'basic_html_with_pre',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], 0, 10), [
          'codeBlock',
        ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], -2)),
      ],
      'plugins' => [
        'ckeditor5_codeBlock' => [
          'languages' => [
            [
              'label' => 'Plain text',
              'language' => 'plaintext',
            ],
            [
              'label' => 'C',
              'language' => 'c',
            ],
            [
              'label' => 'C#',
              'language' => 'cs',
            ],
            [
              'label' => 'C++',
              'language' => 'cpp',
            ],
            [
              'label' => 'CSS',
              'language' => 'css',
            ],
            [
              'label' => 'Diff',
              'language' => 'diff',
            ],
            [
              'label' => 'HTML',
              'language' => 'html',
            ],
            [
              'label' => 'Java',
              'language' => 'java',
            ],
            [
              'label' => 'JavaScript',
              'language' => 'javascript',
            ],
            [
              'label' => 'PHP',
              'language' => 'php',
            ],
            [
              'label' => 'Python',
              'language' => 'python',
            ],
            [
              'label' => 'Ruby',
              'language' => 'ruby',
            ],
            [
              'label' => 'TypeScript',
              'language' => 'typescript',
            ],
            [
              'label' => 'XML',
              'language' => 'xml',
            ],
          ],
        ],
      ] + $basic_html_test_case['expected_ckeditor5_settings']['plugins'],
    ],
    'expected_superset' => '<code class="language-*"> <ol reversed>',
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (with <pre>)";s:25:"%enabling_message_content";s:164:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>) Code Block (for tags: <pre>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (with <pre>)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:23:"Basic HTML (with <pre>)";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Code Block, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   These attributes: <em class="placeholder"> class (for &lt;code&gt;), reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html_with_alignable_p can be switched to CKEditor 5 without problems, align buttons added automatically, but a superset of alignments is enabled" => [
    'format_id' => 'basic_html_with_alignable_p',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], 0, 10), [
          'alignment',
        ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'], -2)),
      ],
      'plugins' => array_merge([
        'ckeditor5_alignment' => [
          'enabled_alignments' => [
            'center',
            'justify',
            'left',
            'right',
          ],
        ],
      ], $basic_html_test_case['expected_ckeditor5_settings']['plugins']),
    ],
    'expected_superset' => implode(' ', [
      // Note that aligning left and right is being added, on top of what the
      // original format allowed: center and justify.
      // Note that aligning left/center/right/justify is possible on *all*
      // allowed CKEditor 5 `$block` text container tags.
      // @todo When https://www.drupal.org/project/drupal/issues/3259367
      //   lands, none of the tags below should appear.
'<p class="text-align-left text-align-right">',
      '<h2 class="text-align-left text-align-center text-align-right text-align-justify">',
      '<h3 class="text-align-left text-align-center text-align-right text-align-justify">',
      '<h4 class="text-align-left text-align-center text-align-right text-align-justify">',
      '<h5 class="text-align-left text-align-center text-align-right text-align-justify">',
      '<h6 class="text-align-left text-align-center text-align-right text-align-justify">',
      '<ol reversed>',
    ]),
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:45:"Basic HTML (with alignable paragraph support)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:45:"Basic HTML (with alignable paragraph support)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'The CKEditor 5 migration process enabled the following plugins to support specific attributes that are allowed by the %text_format text format: %enabled_for_attributes_message_content.',
          'a:2:{s:12:"%text_format";s:45:"Basic HTML (with alignable paragraph support)";s:39:"%enabled_for_attributes_message_content";s:97:"Alignment ( for tag: <p> to support: class with value(s):  text-align-center, text-align-justify)";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:45:"Basic HTML (with alignable paragraph support)";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption, Alignment</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   These attributes: <em class="placeholder"> class (for &lt;p&gt;, &lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;), reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html with media_embed added (3 upgrade messages), but the drupalMedia toolbar item is not added automatically" => [
    'format_id' => 'basic_html_with_media_embed',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'],
      ],
      'plugins' => array_merge($basic_html_test_case['expected_ckeditor5_settings']['plugins'], [
        'media_media' => [
          'allow_view_mode_override' => FALSE,
        ],
      ]),
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:37:"Basic HTML (with Media Embed support)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:37:"Basic HTML (with Media Embed support)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:37:"Basic HTML (with Media Embed support)";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "basic_html with media_embed added with data-view-mode allowed and no view modes configured, but the drupalMedia toolbar item is not added automatically (3 upgrade messages, 1 violation)" => [
    'format_id' => 'basic_html_with_media_embed_view_mode_enabled_no_view_modes_configured',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'],
      ],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], [
            '<drupal-media data-view-mode>',
          ]),
        ],
        'media_media' => [
          'allow_view_mode_override' => FALSE,
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:74:"(with Media Embed support, view mode enabled but no view modes configured)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:74:"(with Media Embed support, view mode enabled but no view modes configured)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:74:"(with Media Embed support, view mode enabled but no view modes configured)";s:19:"@missing_attributes";s:100:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <drupal-media data-view-mode>";}',
        ],
      ],
    ],
    'expected_messages' => array_merge_recursive($basic_html_test_case['expected_messages'], [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt; &lt;drupal-media data-view-mode&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ]),
    'expected_post_filter_drop_fundamental_compatibility_violations' => [],
    'expected_post_update_text_editor_violations' => [
      'settings.plugins.ckeditor5_sourceEditing.allowed_tags.12' => '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">Media (&lt;drupal-media data-view-mode&gt;)</em>.',
    ],
  ];
  yield "basic_html with media_embed added with data-view-mode allowed and 2 view modes configured, but the drupalMedia toolbar item is not added automatically (3 upgrade messages, 1 violation)" => [
    'format_id' => 'basic_html_with_media_embed_view_mode_enabled_two_view_modes_configured',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar']['items'],
      ],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], [
            '<drupal-media data-view-mode>',
          ]),
        ],
        'media_media' => [
          'allow_view_mode_override' => FALSE,
        ],
      ],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:76:"(with Media Embed support, view mode enabled and two view modes configured )";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:76:"(with Media Embed support, view mode enabled and two view modes configured )";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:76:"(with Media Embed support, view mode enabled and two view modes configured )";s:19:"@missing_attributes";s:100:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <drupal-media data-view-mode>";}',
        ],
      ],
    ],
    'expected_messages' => array_merge_recursive($basic_html_test_case['expected_messages'], [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload, Image align, Image caption</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt; &lt;drupal-media data-view-mode&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ]),
    'expected_post_filter_drop_fundamental_compatibility_violations' => [],
    'expected_post_update_text_editor_violations' => [
      'settings.plugins.ckeditor5_sourceEditing.allowed_tags.12' => '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">Media (&lt;drupal-media data-view-mode&gt;)</em>.',
    ],
  ];
  yield "basic_html_with_any_data_attr can be switched to CKEditor 5 without problems (3 upgrade messages)" => [
    'format_id' => 'basic_html_with_any_data_attr',
    'filters_to_drop' => $basic_html_test_case['filters_to_drop'],
    'expected_ckeditor5_settings' => [
      'toolbar' => $basic_html_test_case['expected_ckeditor5_settings']['toolbar'],
      'plugins' => [
        'ckeditor5_heading' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_heading'],
        'ckeditor5_imageResize' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_imageResize'],
        'ckeditor5_list' => $basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_list'],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => array_merge(array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 0, 7), [
            '<img data-*>',
          ], array_slice($basic_html_test_case['expected_ckeditor5_settings']['plugins']['ckeditor5_sourceEditing']['allowed_tags'], 7)),
        ],
      ] + $basic_html_test_case['expected_ckeditor5_settings']['plugins'],
    ],
    'expected_superset' => $basic_html_test_case['expected_superset'],
    'expected_fundamental_compatibility_violations' => $basic_html_test_case['expected_fundamental_compatibility_violations'],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:48:"Basic HTML (with any data-* attribute on images)";s:25:"%enabling_message_content";s:135:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>) Image (for tags: <img>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:48:"Basic HTML (with any data-* attribute on images)";s:19:"@unsupported_string";s:28:"<cite> <dl> <dt> <dd> <span>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:48:"Basic HTML (with any data-* attribute on images)";s:19:"@missing_attributes";s:83:"<a hreflang> <blockquote cite> <img data-*> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List, Image, Image Upload</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;span&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;img data-*&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:   This attribute: <em class="placeholder"> reversed (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "restricted_html can be switched to CKEditor 5 after dropping the two markup-creating filters (3 upgrade messages)" => [
    'format_id' => 'restricted_html',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          '|',
          // Items added based on "allowed tags" config.
          // Because '<a>' is in allowed_html.
'link',
          // Because '<blockquote cite>' is in allowed_html.
'blockQuote',
          // Because '<code>' is in allowed_html.
'code',
          // Because '<ul>' is in allowed_html.
'bulletedList',
          // Because '<ol>' is in allowed_html.
'numberedList',
          // Because additional tags need to be allowed to achieve a superset.
'|',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [
            '<cite>',
            '<dl>',
            '<dt>',
            '<dd>',
            '<a hreflang>',
            '<blockquote cite>',
            '<h2 id>',
            '<h3 id>',
            '<h4 id>',
            '<h5 id>',
            '<h6 id>',
          ],
        ],
      ],
    ],
    'expected_superset' => '<br> <p> <ol reversed>',
    'expected_fundamental_compatibility_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.',
    ],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:15:"Restricted HTML";s:25:"%enabling_message_content";s:111:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:15:"Restricted HTML";s:19:"@unsupported_string";s:21:"<cite> <dl> <dt> <dd>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:15:"Restricted HTML";s:19:"@missing_attributes";s:70:"<a hreflang> <blockquote cite> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
      'warning' => [
        [
          'As part of migrating the %text_format text format to CKEditor 5, the following tag(s) were added to <em>Limit allowed HTML tags and correct faulty HTML</em>, because they are needed to provide fundamental CKEditor 5 functionality : @missing_tags. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:15:"Restricted HTML";s:13:"@missing_tags";s:8:"<br> <p>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following: The &lt;br&gt;, &lt;p&gt; tags were added because they are <a target="_blank" href="/admin/help/ckeditor5#required-tags">required by CKEditor 5</a>. The tags <em class="placeholder">&lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;, &lt;*&gt;, &lt;cite&gt;, &lt;dl&gt;, &lt;dt&gt;, &lt;dd&gt;, &lt;a&gt;, &lt;blockquote&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;code&gt;, &lt;ul&gt;, &lt;ol&gt;, &lt;li&gt;</em>; These attributes: <em class="placeholder"> id (for &lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;), dir (for &lt;*&gt;), lang (for &lt;*&gt;), hreflang (for &lt;a&gt;), href (for &lt;a&gt;), cite (for &lt;blockquote&gt;), type (for &lt;ul&gt;, &lt;ol&gt;), reversed (for &lt;ol&gt;), start (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
    'expected_post_filter_drop_fundamental_compatibility_violations' => [],
  ];
  yield "full_html can be switched to CKEditor 5 (no upgrade messages), uses only default toolbar items because impossible to know toolbar items are desired" => [
    'format_id' => 'full_html',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          // Because there are no HTML restrictions.
'|',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [],
        ],
      ],
    ],
    'expected_superset' => '',
    'expected_fundamental_compatibility_violations' => [],
    'expected_db_logs' => [],
    'expected_messages' => [],
  ];
  yield "filter_only__filter_html can be switched to CKEditor 5 without problems (3 upgrade messages)" => [
    'format_id' => 'filter_only__filter_html',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          '|',
          // Items added based on filter_html's "allowed tags" config.
'link',
          'blockQuote',
          'code',
          'bulletedList',
          'numberedList',
          // Because additional tags need to be allowed to achieve a superset.
'|',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_list' => [
          'properties' => [
            'reversed' => TRUE,
            'startIndex' => TRUE,
            'styles' => TRUE,
          ],
          'multiBlock' => TRUE,
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [
            '<cite>',
            '<dl>',
            '<dt>',
            '<dd>',
            '<a hreflang>',
            '<blockquote cite>',
            '<h2 id="jump-*">',
            '<h3 id>',
            '<h4 id>',
            '<h5 id>',
            '<h6 id>',
          ],
        ],
      ],
    ],
    'expected_superset' => '<br> <p> <ol type reversed>',
    'expected_fundamental_compatibility_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.',
    ],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:54:"Only the "filter_html" filter and its default settings";s:25:"%enabling_message_content";s:111:"Link (for tags: <a>) Block quote (for tags: <blockquote>) Code (for tags: <code>) List (for tags: <ul><ol><li>)";}',
        ],
        [
          'The following tags were permitted by the %text_format text format\'s filter configuration, but no plugin was available that supports them. To ensure the tags remain supported by this text format, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @unsupported_string. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:54:"Only the "filter_html" filter and its default settings";s:19:"@unsupported_string";s:21:"<cite> <dl> <dt> <dd>";}',
        ],
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:54:"Only the "filter_html" filter and its default settings";s:19:"@missing_attributes";s:79:"<a hreflang> <blockquote cite> <h2 id="jump-*"> <h3 id> <h4 id> <h5 id> <h6 id>";}',
        ],
      ],
      'warning' => [
        [
          'As part of migrating the %text_format text format to CKEditor 5, the following tag(s) were added to <em>Limit allowed HTML tags and correct faulty HTML</em>, because they are needed to provide fundamental CKEditor 5 functionality : @missing_tags. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:54:"Only the "filter_html" filter and its default settings";s:13:"@missing_tags";s:8:"<br> <p>";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link, Block quote, Code, List</em>). Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;cite&gt; &lt;dl&gt; &lt;dt&gt; &lt;dd&gt; &lt;a hreflang&gt; &lt;blockquote cite&gt; &lt;h2 id=&quot;jump-*&quot;&gt; &lt;h3 id&gt; &lt;h4 id&gt; &lt;h5 id&gt; &lt;h6 id&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following: The &lt;br&gt;, &lt;p&gt; tags were added because they are <a target="_blank" href="/admin/help/ckeditor5#required-tags">required by CKEditor 5</a>. The tags <em class="placeholder">&lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;, &lt;*&gt;, &lt;cite&gt;, &lt;dl&gt;, &lt;dt&gt;, &lt;dd&gt;, &lt;a&gt;, &lt;blockquote&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;code&gt;, &lt;ul&gt;, &lt;ol&gt;, &lt;li&gt;</em>; These attributes: <em class="placeholder"> id (for &lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;), dir (for &lt;*&gt;), lang (for &lt;*&gt;), hreflang (for &lt;a&gt;), href (for &lt;a&gt;), cite (for &lt;blockquote&gt;), type (for &lt;ul&gt;, &lt;ol&gt;), reversed (for &lt;ol&gt;), start (for &lt;ol&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
  yield "cke4_stylescombo_span can be switched to CKEditor 5 without problems, only <span> in Source Editing" => [
    'format_id' => 'cke4_stylescombo_span',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          // Because additional tags need to be allowed to achieve a superset.
'|',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [
            '<span class="llama">',
          ],
        ],
      ],
    ],
    'expected_superset' => '<h2> <h3> <h4> <h5> <h6> <strong> <em>',
    'expected_fundamental_compatibility_violations' => [],
    'expected_db_logs' => [
      'status' => [
        [
          'As part of migrating to CKEditor 5, it was found that the %text_format text format\'s HTML filters includes plugins that support the following tags, but not some of their attributes. To ensure these attributes remain supported, the following were added to the Source Editing plugin\'s <em>Manually editable HTML tags</em>: @missing_attributes. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:43:"A CKEditor 4 configured to have span styles";s:19:"@missing_attributes";s:20:"<span class="llama">";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following:  Added these tags/attributes to the Source Editing Plugin\'s <a target="_blank" href="/admin/help/ckeditor5#source-editing">Manually editable HTML tags</a> setting: &lt;span class=&quot;llama&quot;&gt;. Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:  The tags <em class="placeholder">&lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;, &lt;strong&gt;, &lt;em&gt;</em>;  Additional details are available in your logs.',
      ],
    ],
  ];
  yield "minimal_ckeditor_wrong_allowed_html does not have sufficient allowed HTML => necessary allowed HTML added (1 upgrade message)" => [
    'format_id' => 'minimal_ckeditor_wrong_allowed_html',
    'filters_to_drop' => [],
    'expected_ckeditor5_settings' => [
      'toolbar' => [
        'items' => [
          // Default toolbar items.
'heading',
          'bold',
          'italic',
          '|',
          'link',
        ],
      ],
      'plugins' => [
        'ckeditor5_heading' => [
          'enabled_headings' => [
            'heading2',
            'heading3',
            'heading4',
            'heading5',
            'heading6',
          ],
        ],
      ],
    ],
    'expected_superset' => '<h2> <h3> <h4> <h5> <h6> <strong> <em> <a href>',
    'expected_fundamental_compatibility_violations' => [],
    'expected_db_logs' => [
      'status' => [
        [
          'The CKEditor 5 migration enabled the following plugins to support tags that are allowed by the %text_format text format: %enabling_message_content. The text format must be saved to make these changes active.',
          'a:2:{s:12:"%text_format";s:52:"Most basic HTML, but with allowed_html misconfigured";s:25:"%enabling_message_content";s:20:"Link (for tags: <a>)";}',
        ],
      ],
    ],
    'expected_messages' => [
      'status' => [
        'To maintain the capabilities of this text format, <a target="_blank" href="/admin/help/ckeditor5#migration-settings">the CKEditor 5 migration</a> did the following: Enabled these plugins: (<em class="placeholder">Link</em>). . Additional details are available in your logs.',
      ],
      'warning' => [
        'Updating to CKEditor 5 added support for some previously unsupported tags/attributes. A plugin introduced support for the following:  The tags <em class="placeholder">&lt;h2&gt;, &lt;h3&gt;, &lt;h4&gt;, &lt;h5&gt;, &lt;h6&gt;, &lt;strong&gt;, &lt;em&gt;</em>; This attribute: <em class="placeholder"> href (for &lt;a&gt;)</em>; Additional details are available in your logs.',
      ],
    ],
  ];
}

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