EntityEmbedTrait.php in Lightning Media 8.3
File
tests/src/Traits/EntityEmbedTrait.php
View source
<?php
namespace Drupal\Tests\lightning_media\Traits;
use Behat\Mink\Element\DocumentElement;
trait EntityEmbedTrait {
private function waitForEmbedForm() {
$embed_form = $this
->assertSession()
->waitForElement('css', 'form.entity-embed-dialog.entity-embed-dialog-step--embed');
$this
->assertNotEmpty($embed_form);
return $embed_form;
}
private function waitForImageEmbedForm() {
$assert_session = $this
->assertSession();
$embed_form = $this
->waitForEmbedForm();
$assert_session
->selectExists('Image style', $embed_form);
$assert_session
->fieldExists('Alternate text', $embed_form);
$assert_session
->fieldExists('Title', $embed_form);
return $embed_form;
}
private function waitForStandardEmbedForm() {
$assert_session = $this
->assertSession();
$embed_form = $this
->waitForEmbedForm();
$assert_session
->fieldNotExists('Image style', $embed_form);
$assert_session
->fieldNotExists('Alternate text', $embed_form);
$assert_session
->fieldNotExists('Title', $embed_form);
return $embed_form;
}
private function submitEmbedForm() {
$this
->waitForEmbedForm();
$this
->assertSession()
->elementExists('css', '.ui-dialog-buttonpane')
->pressButton('Embed');
$result = $this
->getSession()
->getPage()
->waitFor(10, function (DocumentElement $page) {
return $page
->find('css', '.ui-dialog') == NULL;
});
$this
->assertTrue($result);
}
}