function SourceEditingTest::providerAllowingExtraAttributes

Data provider for ::testAllowingExtraAttributes().

Return value

array The test cases.

1 call to SourceEditingTest::providerAllowingExtraAttributes()
SourceEditingTest::testAllowingExtraAttributes in core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php
Tests allowing extra attributes on already supported tags using GHS.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/SourceEditingTest.php, line 142

Class

SourceEditingTest
Tests Drupal\ckeditor5\Plugin\CKEditor5Plugin\SourceEditing.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function providerAllowingExtraAttributes() : array {
  $general_test_case_markup = '<div class="llama" data-llama="🦙"><p data-llama="🦙">The <a href="https://example.com/pirate" class="button" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" class="use-ajax" data-grammar="adjective">irate</a>.</p></div>';
  return [
    'no extra attributes allowed' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '',
    ],
    // Common case: any attribute that is not `style` or `class`.
'<a data-grammar="subject">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<a data-grammar="subject">',
    ],
    '<a data-grammar="adjective">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate" data-grammar="adjective">irate</a>.</p></div>',
      '<a data-grammar="adjective">',
    ],
    '<a data-grammar>' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" data-grammar="adjective">irate</a>.</p></div>',
      '<a data-grammar>',
    ],
    // Edge case: `class`.
'<a class="button">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a class="button" href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<a class="button">',
    ],
    '<a class="use-ajax">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a class="use-ajax" href="https://example.com/irate">irate</a>.</p></div>',
      '<a class="use-ajax">',
    ],
    '<a class>' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a class="button" href="https://example.com/pirate">pirate</a> is <a class="use-ajax" href="https://example.com/irate">irate</a>.</p></div>',
      '<a class>',
    ],
    // Edge case: $text-container wildcard with additional
    // attribute.
'<$text-container data-llama>' => [
      $general_test_case_markup,
      '<div class="llama" data-llama="🦙"><p data-llama="🦙">The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<$text-container data-llama>',
    ],
    // Edge case: $text-container wildcard with stricter attribute
    // constrain.
'<$text-container class="not-llama">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<$text-container class="not-llama">',
    ],
    // Edge case: wildcard attribute names:
    // - prefix, f.e. `data-*`
    // - infix, f.e. `*gramma*`
    // - suffix, f.e. `*-grammar`
'<a data-*>' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" data-grammar="adjective">irate</a>.</p></div>',
      '<a data-*>',
    ],
    '<a *gramma*>' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" data-grammar="adjective">irate</a>.</p></div>',
      '<a *gramma*>',
    ],
    '<a *-grammar>' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate" data-grammar="adjective">irate</a>.</p></div>',
      '<a *-grammar>',
    ],
    // Edge case: concrete attribute with wildcard class value.
'<a class="use-*">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate">pirate</a> is <a class="use-ajax" href="https://example.com/irate">irate</a>.</p></div>',
      '<a class="use-*">',
    ],
    // Edge case: concrete attribute with wildcard attribute value.
'<a data-grammar="sub*">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<a data-grammar="sub*">',
    ],
    // Edge case: `data-*` with wildcard attribute value.
'<a data-*="sub*">' => [
      $general_test_case_markup,
      '<div class="llama"><p>The <a href="https://example.com/pirate" data-grammar="subject">pirate</a> is <a href="https://example.com/irate">irate</a>.</p></div>',
      '<a data-*="sub*">',
    ],
  ];
}

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