function SmartDefaultSettingsTest::providerSurplusScore

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

Data provider for testing computeSurplusScore().

Return value

\Generator

File

core/modules/ckeditor5/tests/src/Unit/SmartDefaultSettingsTest.php, line 37

Class

SmartDefaultSettingsTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21ckeditor5%21src%21SmartDefaultSettings.php/class/SmartDefaultSettings/9" title="Generates CKEditor 5 settings for existing text editors/formats." class="local">\Drupal\ckeditor5\SmartDefaultSettings</a> @group ckeditor5

Namespace

Drupal\Tests\ckeditor5\Unit

Code

public function providerSurplusScore() : \Generator {
    $needed = new HTMLRestrictions([
        'code' => FALSE,
    ]);
    (yield 'surplus: 1 tag, 1 attribute, 1 attribute with wildcard restriction' => [
        HTMLRestrictions::fromString('<pre> <code class="language-*">'),
        $needed,
        1001010,
    ]);
    (yield 'surplus: 1 tag, 1 attribute, 2 allowed attribute values' => [
        HTMLRestrictions::fromString('<code class="language-php language-js">'),
        $needed,
        1002,
    ]);
    (yield 'surplus: 2 attributes, 4 allowed attribute values' => [
        // cSpell:disable-next-line
HTMLRestrictions::fromString('<code class="language-php language-js" data-library="highlightjs something">'),
        $needed,
        2004,
    ]);
    (yield 'surplus: 1 any attribute allowed' => [
        HTMLRestrictions::fromString('<code *>'),
        $needed,
        100000,
    ]);
    (yield 'surplus: 1 attribute, 1 attribute any value allowed' => [
        HTMLRestrictions::fromString('<code class>'),
        $needed,
        1100,
    ]);
    (yield 'surplus: 1 tag, 2 wildcard attributes, 2 attributes, 3 attributes any value allowed, 1 wildcard allowed attribute value ' => [
        HTMLRestrictions::fromString('<pre> <code data-config-* data-options-* data-highlight-library class="language-*">'),
        $needed,
        1022310,
    ]);
}

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