function CKEditor4to5UpgradeCompletenessTest::testButtons

Tests that all CKEditor 4 buttons in core have an upgrade path.

1 call to CKEditor4to5UpgradeCompletenessTest::testButtons()
CKEditor4to5UpgradeCompletenessTest::testButtonsWithTestOnlyModule in core/modules/ckeditor5/tests/src/Kernel/CKEditor4to5UpgradeCompletenessTest.php
Tests that the test-only CKEditor 4 module does not have an upgrade path.

File

core/modules/ckeditor5/tests/src/Kernel/CKEditor4to5UpgradeCompletenessTest.php, line 103

Class

CKEditor4to5UpgradeCompletenessTest
@covers \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Core @group ckeditor5 @internal

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function testButtons() : void {
    $cke4_buttons = array_keys(NestedArray::mergeDeepArray($this->cke4PluginManager
        ->getButtons()));
    $cke4_buttons = array_merge($cke4_buttons, self::CONTRIB_BUTTONS_NOW_IN_CORE);
    foreach ($cke4_buttons as $button) {
        $equivalent = $this->upgradePluginManager
            ->mapCKEditor4ToolbarButtonToCKEditor5ToolbarItem($button, HTMLRestrictions::emptySet());
        $this->assertTrue($equivalent === NULL || is_array($equivalent) && Inspector::assertAllStrings($equivalent));
        // The returned equivalent CKEditor 5 toolbar item(s) must exist.
        if (is_string($equivalent)) {
            foreach (explode(',', $equivalent) as $equivalent_cke5_toolbar_item) {
                $this->assertArrayHasKey($equivalent_cke5_toolbar_item, $this->cke5PluginManager
                    ->getToolbarItems());
            }
        }
    }
}

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