CKEditor5UpdatePluginSettingsSortTest.php

Same filename in other branches
  1. 10 core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdatePluginSettingsSortTest.php

Namespace

Drupal\Tests\ckeditor5\Functional\Update

File

core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdatePluginSettingsSortTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\ckeditor5\Functional\Update;

use Drupal\editor\Entity\Editor;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;

/**
 * @covers ckeditor5_post_update_plugins_settings_export_order
 * @group Update
 * @group ckeditor5
 */
class CKEditor5UpdatePluginSettingsSortTest extends UpdatePathTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * {@inheritdoc}
     */
    protected function setDatabaseDumpFiles() {
        $this->databaseDumpFiles = [
            __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz',
        ];
    }
    
    /**
     * Ensure settings for CKEditor 5 plugins are sorted by plugin key.
     */
    public function testUpdatePluginSettingsSortPostUpdate() : void {
        $editor = Editor::load('basic_html');
        $settings = $editor->getSettings();
        $plugin_settings_before = array_keys($settings['plugins']);
        $this->runUpdates();
        $editor = Editor::load('basic_html');
        $settings = $editor->getSettings();
        $plugin_settings_after = array_keys($settings['plugins']);
        // Different sort before and after, but the same values.
        $this->assertNotSame($plugin_settings_before, $plugin_settings_after);
        sort($plugin_settings_before);
        $this->assertSame($plugin_settings_before, $plugin_settings_after);
    }
    
    /**
     * Ensure settings for CKEditor 5 plugins are sorted by plugin key.
     */
    public function testUpdatePluginSettingsSortEntitySave() : void {
        $editor = Editor::load('basic_html');
        $settings = $editor->getSettings();
        $plugin_settings_before = array_keys($settings['plugins']);
        $editor->save();
        $editor = Editor::load('basic_html');
        $settings = $editor->getSettings();
        $plugin_settings_after = array_keys($settings['plugins']);
        // Different sort before and after, but the same values.
        $this->assertNotSame($plugin_settings_before, $plugin_settings_after);
        sort($plugin_settings_before);
        $this->assertSame($plugin_settings_before, $plugin_settings_after);
    }

}

Classes

Title Deprecated Summary
CKEditor5UpdatePluginSettingsSortTest @covers ckeditor5_post_update_plugins_settings_export_order @group Update @group ckeditor5

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