You are here

public function CKEditorMediaBrowserTest::testDocumentEmbed in Lightning Media 8.3

Tests that the image embed plugin is not used to embed a document.

File

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

Class

CKEditorMediaBrowserTest
Tests the media browser's integration with CKEditor.

Namespace

Drupal\Tests\lightning_media\FunctionalJavascript

Code

public function testDocumentEmbed() {
  $session = $this
    ->getSession();
  $uri = uniqid('public://') . '.txt';
  file_put_contents($uri, $this
    ->getRandomGenerator()
    ->paragraphs());
  $file = File::create([
    'uri' => $uri,
  ]);
  $file
    ->save();
  $this
    ->addMedia([
    'bundle' => 'document',
    'field_document' => $file
      ->id(),
  ]);
  $this
    ->drupalGet('/node/add/page');
  $this
    ->open();
  $items = $this
    ->waitForItems();
  $this
    ->selectItem($items[0]);
  $session
    ->getPage()
    ->pressButton('Place');
  $session
    ->switchToIFrame(NULL);
  $this
    ->waitForStandardEmbedForm();
}