function TableTest::setUp

Same name in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\TableTest::setUp()
  2. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\TableTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/TableTest.php, line 62

Class

TableTest
For testing the table plugin.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    FilterFormat::create([
        'format' => 'test_format',
        'name' => 'Test format',
        'filters' => [
            'filter_html' => [
                'status' => TRUE,
                'settings' => [
                    'allowed_html' => '<br> <p> <table> <tr> <td rowspan colspan> <th rowspan colspan> <thead> <tbody> <tfoot> <caption>',
                ],
            ],
        ],
    ])->save();
    Editor::create([
        'editor' => 'ckeditor5',
        'format' => 'test_format',
        'image_upload' => [
            'status' => FALSE,
        ],
        'settings' => [
            'toolbar' => [
                'items' => [
                    'insertTable',
                    'sourceEditing',
                ],
            ],
            'plugins' => [
                'ckeditor5_sourceEditing' => [
                    'allowed_tags' => [],
                ],
            ],
        ],
    ])->save();
    $this->assertSame([], array_map(function (ConstraintViolationInterface $v) {
        return (string) $v->getMessage();
    }, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
    // Create a sample host entity.
    $this->host = $this->createNode([
        'type' => 'page',
        'title' => 'Animals with strange names',
        'body' => [
            'value' => '<p>some content that will likely change</p>',
            'format' => 'test_format',
        ],
    ]);
    $this->host
        ->save();
    $this->drupalLogin($this->drupalCreateUser([
        'use text format test_format',
        'bypass node access',
    ]));
}

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