function EntityLinkSuggestionsTest::setUp

Overrides CKEditor5TestBase::setUp

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/EntityLinkSuggestionsTest.php, line 46

Class

EntityLinkSuggestionsTest
For testing the drupalEntityLinkSuggestions plugin.

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function setUp() : void {
  parent::setUp();
  // Create text format, associate CKEditor 5, validate.
  FilterFormat::create([
    'format' => 'test_format',
    'name' => 'Test format',
    'filters' => [
      'filter_html' => [
        'status' => TRUE,
        'settings' => [
          'allowed_html' => '<p> <br> <a href data-entity-type data-entity-uuid data-entity-metadata>',
        ],
      ],
      'entity_links' => [
        'status' => TRUE,
      ],
    ],
  ])->save();
  Editor::create([
    'format' => 'test_format',
    'editor' => 'ckeditor5',
    'image_upload' => [
      'status' => FALSE,
    ],
    'settings' => [
      'toolbar' => [
        'items' => [
          'link',
        ],
      ],
    ],
  ])->save();
  $this->assertExpectedCkeditor5Violations();
  // Create an account with "f" in the username.
  $account = $this->drupalCreateUser([
    'create page content',
    'edit any page content',
    'use text format test_format',
  ]);
  // Create a document media item with "f" in the name.
  $this->createMediaType('file', [
    'id' => 'document',
    'label' => 'Document',
  ]);
  File::create([
    'uri' => $this->getTestFiles('text')[0]->uri,
  ])
    ->save();
  Media::create([
    'bundle' => 'document',
    'name' => 'Information about screaming hairy armadillo',
    'field_media_file' => [
      [
        'target_id' => 1,
      ],
    ],
  ])->save();
  $this->drupalLogin($account);
}

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