You are here

public function CKEditorIntegrationTest::testOnlyDrupalMediaTagProcessed in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::testOnlyDrupalMediaTagProcessed()

Tests that only <drupal-media> tags are processed.

See also

\Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testOnlyDrupalMediaTagProcessed()

File

core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php, line 166

Class

CKEditorIntegrationTest
@coversDefaultClass \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia @group media

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

public function testOnlyDrupalMediaTagProcessed() {
  $original_value = $this->host->body->value;
  $this->host->body->value = str_replace('drupal-media', 'p', $original_value);
  $this->host
    ->save();

  // Assert that `<p data-* …>` is not upcast into a CKEditor Widget.
  $this
    ->drupalGet($this->host
    ->toUrl('edit-form'));
  $this
    ->waitForEditor();
  $this
    ->assignNameToCkeditorIframe();
  $this
    ->getSession()
    ->switchToIFrame('ckeditor');
  $assert_session = $this
    ->assertSession();
  $this
    ->assertEmpty($assert_session
    ->waitForElementVisible('css', 'img[src*="image-test.png"]', 1000));
  $assert_session
    ->elementNotExists('css', 'figure');
  $this->host->body->value = $original_value;
  $this->host
    ->save();

  // Assert that `<drupal-media data-* …>` is upcast into a CKEditor Widget.
  $this
    ->getSession()
    ->reload();
  $this
    ->waitForEditor();
  $this
    ->assignNameToCkeditorIframe();
  $this
    ->getSession()
    ->switchToIFrame('ckeditor');
  $this
    ->assertNotEmpty($assert_session
    ->waitForElementVisible('css', 'img[src*="image-test.png"]'));
  $assert_session
    ->elementExists('css', 'figure');
}