function CKEditor5UpdateCodeBlockConfigurationTest::testUpdateCodeBlockConfigurationPostUpdate

Same name and namespace in other branches
  1. 10 core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateCodeBlockConfigurationTest.php \Drupal\Tests\ckeditor5\Functional\Update\CKEditor5UpdateCodeBlockConfigurationTest::testUpdateCodeBlockConfigurationPostUpdate()

Ensure default configuration for the CKEditor 5 codeBlock plugin is added.

File

core/modules/ckeditor5/tests/src/Functional/Update/CKEditor5UpdateCodeBlockConfigurationTest.php, line 34

Class

CKEditor5UpdateCodeBlockConfigurationTest
@covers ckeditor5_post_update_code_block @group Update @group ckeditor5

Namespace

Drupal\Tests\ckeditor5\Functional\Update

Code

public function testUpdateCodeBlockConfigurationPostUpdate() : void {
    $editor = Editor::load('full_html');
    $settings = $editor->getSettings();
    $this->assertArrayNotHasKey('ckeditor5_codeBlock', $settings['plugins']);
    $this->runUpdates();
    $editor = Editor::load('full_html');
    $settings = $editor->getSettings();
    $this->assertArrayHasKey('ckeditor5_codeBlock', $settings['plugins']);
    // @see \Drupal\ckeditor5\Plugin\CKEditor5Plugin\CodeBlock::defaultConfiguration()
    $this->assertSame([
        'languages' => [
            [
                'label' => 'Plain text',
                'language' => 'plaintext',
            ],
            [
                'label' => 'C',
                'language' => 'c',
            ],
            [
                'label' => 'C#',
                'language' => 'cs',
            ],
            [
                'label' => 'C++',
                'language' => 'cpp',
            ],
            [
                'label' => 'CSS',
                'language' => 'css',
            ],
            [
                'label' => 'Diff',
                'language' => 'diff',
            ],
            [
                'label' => 'HTML',
                'language' => 'html',
            ],
            [
                'label' => 'Java',
                'language' => 'java',
            ],
            [
                'label' => 'JavaScript',
                'language' => 'javascript',
            ],
            [
                'label' => 'PHP',
                'language' => 'php',
            ],
            [
                'label' => 'Python',
                'language' => 'python',
            ],
            [
                'label' => 'Ruby',
                'language' => 'ruby',
            ],
            [
                'label' => 'TypeScript',
                'language' => 'typescript',
            ],
            [
                'label' => 'XML',
                'language' => 'xml',
            ],
        ],
    ], $settings['plugins']['ckeditor5_codeBlock']);
}

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