public function CkEditorMediaBrowserTest::testDocumentEmbed in Lightning Media 8.2
Tests that the image embed plugin is not used to embed a document.
@depends testExposedFilters
File
- tests/
src/ ExistingSiteJavascript/ CkEditorMediaBrowserTest.php, line 223
Class
- CkEditorMediaBrowserTest
- @group lightning @group lightning_media
Namespace
Drupal\Tests\lightning_media\ExistingSiteJavascriptCode
public function testDocumentEmbed() {
$session = $this
->getSession();
/** @var \Drupal\Core\Entity\EntityStorageInterface $file_storage */
$file_storage = $this->container
->get('entity_type.manager')
->getStorage('file');
$uri = uniqid('public://') . '.txt';
file_put_contents($uri, $this
->getRandomGenerator()
->paragraphs());
$file = $file_storage
->create([
'uri' => $uri,
]);
$file_storage
->save($file);
$this
->addMedia([
'bundle' => 'document',
'field_document' => $file
->id(),
]);
$this
->visit('/node/add/page');
$this
->open();
$session
->switchToIFrame('entity_browser_iframe_media_browser');
$this->assert
->fieldExists('Type')
->selectOption('Document');
$this
->applyFilters();
$items = $this
->getItems();
$this
->assertGreaterThanOrEqual(1, count($items));
$items[0]
->click();
$this->assert
->buttonExists('Place')
->press();
$session
->switchToIFrame(NULL);
$this->assert
->assertWaitOnAjaxRequest();
$embed_dialog = $this->assert
->elementExists('css', 'form.entity-embed-dialog');
$this->assert
->fieldNotExists('Image style', $embed_dialog);
$this->assert
->fieldNotExists('Alternative text', $embed_dialog);
$this->assert
->fieldNotExists('attributes[title]', $embed_dialog);
}