function MediaTest::testConversion

Same name and namespace in other branches
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testConversion()
  2. 11.x core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testConversion()

Tests that `<drupal-media>` is converted into a block element.

1 call to MediaTest::testConversion()
MediaTest::testDrupalMedia in core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php
Tests the drupal-media tag.

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php, line 45

Class

MediaTest
@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media[[api-linebreak]] @group ckeditor5 @group #slow @internal

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript

Code

protected function testConversion() : void {
  // Wrap the `<drupal-media>` markup in a `<p>`.
  $original_value = $this->host->body->value;
  $this->host->body->value = '<p>foo' . $original_value . '</p>';
  $this->host
    ->save();
  $this->drupalGet($this->host
    ->toUrl('edit-form'));
  $this->waitForEditor();
  $assert_session = $this->assertSession();
  $assert_session->waitForElementVisible('css', 'img[src*="image-test.png"]', 1000);
  $editor_html = $this->getEditorDataAsHtmlString();
  // Observe that `<drupal-media>` was moved into its own block element.
  $this->assertEquals('<p>foo</p>' . $original_value, str_replace('&nbsp;', '', $editor_html));
}

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