function CKEditorIntegrationTest::setCaption

Sets the text of the editable caption to the given text.

Parameters

string $text: The text to set in the caption.

1 call to CKEditorIntegrationTest::setCaption()
CKEditorIntegrationTest::testEditableCaption in core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
Tests caption editing in the CKEditor widget.

File

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

Class

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

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

protected function setCaption($text) {
    $this->getSession()
        ->switchToIFrame();
    $select_and_edit_caption = "var editor = CKEDITOR.instances['edit-body-0-value'];\n       var figcaption = editor.widgets.getByElement(editor.editable().findOne('figcaption'));\n       figcaption.editables.caption.setData('" . $text . "')";
    $this->getSession()
        ->executeScript($select_and_edit_caption);
}

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