function CKEditorIntegrationTest::getDrupalMediaFromSource

Parses the <drupal-media> element from CKEditor's "source" view.

Assumes CKEditor is in source mode.

Return value

\DOMNode|null The drupal-media element or NULL if it can't be found.

3 calls to CKEditorIntegrationTest::getDrupalMediaFromSource()
CKEditorIntegrationTest::assertSourceAttributeSame in core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
Verifies value of an attribute on the downcast <drupal-media> element.
CKEditorIntegrationTest::testAlignment in core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
Tests alignment integration.
CKEditorIntegrationTest::testViewMode in core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
Tests the EditorMediaDialog can set the data-view-mode attribute.

File

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

Class

CKEditorIntegrationTest
@coversDefaultClass \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia[[api-linebreak]] @group media

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

protected function getDrupalMediaFromSource() {
  $value = $this->assertSession()
    ->elementExists('css', 'textarea.cke_source')
    ->getValue();
  $dom = Html::load($value);
  $xpath = new \DOMXPath($dom);
  $list = $xpath->query('//drupal-media');
  return count($list) > 0 ? $list[0] : NULL;
}

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