You are here

protected function MediaTest::getDrupalMediaFromSource in Drupal 10

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 1593

Class

MediaTest
@coversDefaultClass \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalMedia @group ckeditor

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;
}