You are here

private function CKEditorMediaBrowserTest::open in Lightning Media 8.3

Opens the CKeditor media browser.

Parameters

bool $switch: (optional) If TRUE, switch into the media browser iFrame. Defaults to TRUE.

callable $pre_open: (optional) A callback function run before opening the media browser, for example to run some additional JavaScript. Defaults to NULL.

5 calls to CKEditorMediaBrowserTest::open()
CKEditorMediaBrowserTest::testDocumentEmbed in tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php
Tests that the image embed plugin is not used to embed a document.
CKEditorMediaBrowserTest::testEditEmbed in tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php
Tests that the entity embed dialog opens when editing a pre-existing embed.
CKEditorMediaBrowserTest::testExposedFilters in tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php
Tests exposed filters in the media browser.
CKEditorMediaBrowserTest::testImageEmbed in tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php
Tests that the image embed plugin is used to embed an image.
CKEditorMediaBrowserTest::testUnlimitedCardinality in tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php
Tests that cardinality is never enforced in the media browser.

File

tests/src/FunctionalJavascript/CKEditorMediaBrowserTest.php, line 287

Class

CKEditorMediaBrowserTest
Tests the media browser's integration with CKEditor.

Namespace

Drupal\Tests\lightning_media\FunctionalJavascript

Code

private function open($switch = TRUE, callable $pre_open = NULL) {
  $session = $this
    ->getSession();

  // Wait for CKEditor to be ready.
  $this
    ->assertJsCondition('typeof CKEDITOR.instances === "object"');

  // Assert that we have a valid list of CKeditor instance IDs.

  /** @var array $editors */
  $editors = $session
    ->evaluateScript('Object.keys(CKEDITOR.instances)');
  $this
    ->assertSame('array', gettype($editors));
  $this
    ->assertNotEmpty($editors);

  // Assert that the editor is ready.
  $editor = $editors[0];
  $this
    ->assertJsCondition("CKEDITOR.instances['{$editor}'].status === 'ready'");
  if ($pre_open) {
    $pre_open($editor);
  }
  $status = $session
    ->evaluateScript("CKEDITOR.instances['{$editor}'].execCommand('editdrupalentity', { id: 'media_browser' });");
  $this
    ->assertNotEmpty($status);
  if ($switch) {
    $this
      ->waitForEntityBrowser('ckeditor_media_browser', $switch);
  }
}