function MediaTest::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.

File

core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php, line 1594

Class

MediaTest
@coversDefaultClass \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalMedia[[api-linebreak]] @group ckeditor @group legacy

Namespace

Drupal\Tests\ckeditor\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.