function CKEditor4to5UpgradeCompletenessTest::testSettings

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

1 call to CKEditor4to5UpgradeCompletenessTest::testSettings()
CKEditor4to5UpgradeCompletenessTest::testSettingsWithTestOnlyModule 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 135

Class

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

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function testSettings() : void {
    $cke4_configurable_plugins = [];
    foreach ($this->cke4PluginManager
        ->getDefinitions() as $plugin_id => $definition) {
        // Special case: DrupalImage.
        // @see \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImage
        // @see \Drupal\editor\Entity\Editor::getImageUploadSettings()
        if ($plugin_id === 'drupalimage') {
            continue;
        }
        if (is_subclass_of($definition['class'], CKEditorPluginConfigurableInterface::class)) {
            $cke4_configurable_plugins[] = $plugin_id;
        }
    }
    foreach ($cke4_configurable_plugins as $plugin_id) {
        $cke5_plugin_settings = $this->upgradePluginManager
            ->mapCKEditor4SettingsToCKEditor5Configuration($plugin_id, []);
        $this->assertTrue($cke5_plugin_settings === NULL || is_array($cke5_plugin_settings));
        // The returned equivalent CKEditor 5 plugin must exist.
        if (is_array($cke5_plugin_settings)) {
            $cke5_plugin_id = array_keys($cke5_plugin_settings)[0];
            $this->assertArrayHasKey($cke5_plugin_id, $this->cke5PluginManager
                ->getDefinitions());
        }
    }
}

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