function CKEditor5IntegrationTest::setUp

Overrides BrowserTestBase::setUp

File

core/modules/quickedit/tests/src/FunctionalJavascript/CKEditor5IntegrationTest.php, line 47

Class

CKEditor5IntegrationTest
Tests that Quick Edit can load CKEditor 5.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    // Create text format, associate CKEditor 5, validate.
    FilterFormat::create([
        'format' => 'some_format',
        'name' => 'Some format',
        'filters' => [
            'filter_html' => [
                'status' => TRUE,
                'settings' => [
                    'allowed_html' => '<p> <br> <h2> <h3> <h4> <h5> <h6> <strong> <em>',
                ],
            ],
        ],
    ])->save();
    Editor::create([
        'format' => 'some_format',
        'editor' => 'ckeditor5',
        'settings' => [
            'toolbar' => [
                'items' => [
                    'heading',
                    'bold',
                    'italic',
                ],
            ],
            'plugins' => [
                'ckeditor5_heading' => [
                    'enabled_headings' => [
                        'heading2',
                        'heading3',
                        'heading4',
                        'heading5',
                        'heading6',
                    ],
                ],
            ],
        ],
        'image_upload' => [
            'status' => FALSE,
        ],
    ])->save();
    $this->assertSame([], array_map(function (ConstraintViolation $v) {
        return (string) $v->getMessage();
    }, iterator_to_array(CKEditor5::validatePair(Editor::load('some_format'), FilterFormat::load('some_format')))));
    // Create the Article node type.
    $this->drupalCreateContentType([
        'type' => 'article',
        'name' => 'Article',
    ]);
    // Log in as a content author who can use Quick Edit and edit Articles.
    $this->contentAuthorUser = $this->drupalCreateUser([
        'access contextual links',
        'access toolbar',
        'access in-place editing',
        'access content',
        'create article content',
        'edit any article content',
        'use text format some_format',
    ]);
    $this->drupalLogin($this->contentAuthorUser);
}

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