You are here

protected function EmphasisTest::setUp in Drupal 10

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php, line 55

Class

EmphasisTest
Tests emphasis in CKEditor 5.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  FilterFormat::create([
    'format' => 'test_format',
    'name' => 'Test format',
    'filters' => [
      'filter_html' => [
        'status' => TRUE,
        'settings' => [
          'allowed_html' => '<p> <br> <em>',
        ],
      ],
    ],
  ])
    ->save();
  Editor::create([
    'editor' => 'ckeditor5',
    'format' => 'test_format',
    'settings' => [
      'toolbar' => [
        'items' => [
          'italic',
          'sourceEditing',
        ],
      ],
      'plugins' => [
        'ckeditor5_sourceEditing' => [
          'allowed_tags' => [],
        ],
      ],
    ],
  ])
    ->save();
  $this
    ->assertSame([], array_map(function (ConstraintViolation $v) {
    return (string) $v
      ->getMessage();
  }, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
  $this->adminUser = $this
    ->drupalCreateUser([
    'use text format test_format',
    'bypass node access',
  ]);
  $this
    ->drupalCreateContentType([
    'type' => 'blog',
  ]);
  $this->host = $this
    ->createNode([
    'type' => 'blog',
    'title' => 'Animals with strange names',
    'body' => [
      'value' => '<p>This is a <em>test!</em></p>',
      'format' => 'test_format',
    ],
  ]);
  $this->host
    ->save();
  $this
    ->drupalLogin($this->adminUser);
}