class MediaImageTest in Entity Embed 8
Test Media Image specific functionality.
@group entity_embed
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses FunctionalTestSetupTrait, TestSetupTrait, AssertLegacyTrait, BlockCreationTrait, ConfigTestTrait, ContentTypeCreationTrait, NodeCreationTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\Tests\entity_embed\FunctionalJavascript\EntityEmbedTestBase
- class \Drupal\Tests\entity_embed\FunctionalJavascript\MediaImageTest uses ContentTypeCreationTrait, TestFileCreationTrait
- class \Drupal\Tests\entity_embed\FunctionalJavascript\EntityEmbedTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
Expanded class hierarchy of MediaImageTest
File
- tests/
src/ FunctionalJavascript/ MediaImageTest.php, line 19
Namespace
Drupal\Tests\entity_embed\FunctionalJavascriptView source
class MediaImageTest extends EntityEmbedTestBase {
use ContentTypeCreationTrait;
use TestFileCreationTrait;
/**
* The user to use during testing.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* The sample Media entity to embed.
*
* @var \Drupal\media\MediaInterface
*/
protected $media;
/**
* A host entity with a body field to embed media in.
*
* @var \Drupal\node\NodeInterface
*/
protected $host;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stable';
/**
* {@inheritdoc}
*/
public static $modules = [
'entity_embed_test',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Note that media_install() grants 'view media' to all users by default.
$this->adminUser = $this
->drupalCreateUser([
'use text format full_html',
'bypass node access',
]);
$this
->createNode([
'type' => 'article',
'title' => 'Red-lipped batfish',
]);
// Create a sample media entity to be embedded.
File::create([
'uri' => $this
->getTestFiles('image')[0]->uri,
])
->save();
$this->media = Media::create([
'bundle' => 'image',
'name' => 'Screaming hairy armadillo',
'field_media_image' => [
[
'target_id' => 1,
'alt' => 'default alt',
'title' => 'default title',
],
],
]);
$this->media
->save();
// Create a sample host entity to embed media in.
$this
->drupalCreateContentType([
'type' => 'blog',
]);
$this->host = $this
->createNode([
'type' => 'blog',
'title' => 'Animals with strange names',
'body' => [
'value' => '',
'format' => 'full_html',
],
]);
$this->host
->save();
$this
->drupalLogin($this->adminUser);
}
/**
* Tests alt and title overriding for embedded images.
*/
public function testAltAndTitle() {
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->pressEditorButton('test_node');
$this
->assertSession()
->waitForId('drupal-modal');
// Test that node embed doesn't display alt and title fields.
$this
->assertSession()
->fieldExists('entity_id')
->setValue('Red-lipped batfish (1)');
$this
->assertSession()
->elementExists('css', 'button.js-button-next')
->click();
$form = $this
->assertSession()
->waitForElementVisible('css', 'form.entity-embed-dialog-step--embed');
// Assert that the review step displays the selected entity with the label.
$text = $form
->getText();
$this
->assertStringContainsString('Red-lipped batfish', $text);
$select = $this
->assertSession()
->selectExists('attributes[data-entity-embed-display]');
$select
->setValue('view_mode:node.full');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// The view_mode:node.full display shouldn't have alt and title fields.
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
$select = $this
->assertSession()
->selectExists('attributes[data-entity-embed-display]');
$select
->setValue('view_mode:node.teaser');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// The view_mode:node.teaser display shouldn't have alt and title fields.
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
// Close the dialog.
$this
->assertSession()
->elementExists('css', '.ui-dialog-titlebar-close')
->press();
// Now test with media.
$this
->pressEditorButton('test_media_entity_embed');
$this
->assertSession()
->waitForId('drupal-modal');
$this
->assertSession()
->fieldExists('entity_id')
->setValue('Screaming hairy armadillo (1)');
$this
->assertSession()
->elementExists('css', 'button.js-button-next')
->click();
$form = $this
->assertSession()
->waitForElementVisible('css', 'form.entity-embed-dialog-step--embed');
// Assert that the review step displays the selected entity with the label.
$text = $form
->getText();
$this
->assertStringContainsString('Screaming hairy armadillo', $text);
$select = $this
->assertSession()
->selectExists('attributes[data-entity-embed-display]');
$select
->setValue('entity_reference:entity_reference_entity_id');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// The entity_reference:entity_reference_entity_id display shouldn't have
// alt and title fields.
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
$select
->setValue('entity_reference:entity_reference_label');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// The entity_reference:entity_reference_label display shouldn't have alt
// and title fields.
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
// Test the entity embed display that ships with core media.
$select
->setValue('entity_reference:media_thumbnail');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->selectExists('attributes[data-entity-embed-display]')
->setValue('view_mode:media.embed');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$alt = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertEquals($this->media->field_media_image->alt, $alt
->getAttribute('placeholder'));
$title = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]');
$this
->assertEquals($this->media->field_media_image->title, $title
->getAttribute('placeholder'));
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals("default alt", $img
->getAttribute('alt'));
$this
->assertEquals("default title", $img
->getAttribute('title'));
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]')
->setValue('Satanic leaf-tailed gecko alt');
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]')
->setValue('Satanic leaf-tailed gecko title');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals("Satanic leaf-tailed gecko alt", $img
->getAttribute('alt'));
$this
->assertEquals("Satanic leaf-tailed gecko title", $img
->getAttribute('title'));
$this
->reopenDialog();
// Test a view mode that displays thumbnail field.
$select
->setValue('view_mode:media.thumb');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->selectExists('attributes[data-entity-embed-display]')
->setValue('view_mode:media.embed');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$alt = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertEquals('Satanic leaf-tailed gecko alt', $alt
->getValue());
$title = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]');
$this
->assertEquals('Satanic leaf-tailed gecko title', $title
->getValue());
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('Satanic leaf-tailed gecko alt', $img
->getAttribute('alt'));
$this
->assertEquals('Satanic leaf-tailed gecko title', $img
->getAttribute('title'));
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]')
->setValue('Goblin shark alt');
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]')
->setValue('Goblin shark title');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals("Goblin shark alt", $img
->getAttribute('alt'));
$this
->assertEquals("Goblin shark title", $img
->getAttribute('title'));
$this
->reopenDialog();
// Test a view mode that displays the media's image field.
$select
->setValue('view_mode:media.embed');
$this
->assertSession()
->assertWaitOnAjaxRequest();
// Test that the view_mode:media.embed display has alt and title fields,
// and that the default values match the values on the media's
// source image field.
$this
->assertSession()
->selectExists('attributes[data-entity-embed-display]')
->setValue('view_mode:media.embed');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$alt = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertEquals("Goblin shark alt", $alt
->getValue());
$title = $this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]');
$this
->assertEquals("Goblin shark title", $title
->getValue());
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals("Goblin shark alt", $img
->getAttribute('alt'));
$this
->assertEquals("Goblin shark title", $img
->getAttribute('title'));
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]')
->setValue('Satanic leaf-tailed gecko alt');
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]')
->setValue('Satanic leaf-tailed gecko title');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('Satanic leaf-tailed gecko alt', $img
->getAttribute('alt'));
$this
->assertEquals('Satanic leaf-tailed gecko title', $img
->getAttribute('title'));
$this
->config('field.field.media.image.field_media_image')
->set('settings.alt_field', FALSE)
->set('settings.title_field', FALSE)
->save();
drupal_flush_all_caches();
$this
->reopenDialog();
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('default alt', $img
->getAttribute('alt'));
$this
->assertEquals('default title', $img
->getAttribute('title'));
$field = FieldConfig::load('media.image.field_media_image');
$settings = $field
->getSettings();
$settings['alt_field'] = TRUE;
$field
->set('settings', $settings);
$field
->save();
drupal_flush_all_caches();
$this
->reopenDialog();
// Test that when only the alt field is enabled, only alt field should
// display.
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][alt]')
->setValue('Satanic leaf-tailed gecko alt');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][title]');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('Satanic leaf-tailed gecko alt', $img
->getAttribute('alt'));
$this
->assertEquals('default title', $img
->getAttribute('title'));
$field = FieldConfig::load('media.image.field_media_image');
$settings = $field
->getSettings();
$settings['alt_field'] = FALSE;
$settings['title_field'] = TRUE;
$field
->set('settings', $settings);
$field
->save();
drupal_flush_all_caches();
$this
->reopenDialog();
// With only title field enabled, only title field should display.
$this
->assertSession()
->fieldExists('attributes[data-entity-embed-display-settings][title]')
->setValue('Satanic leaf-tailed gecko title');
$this
->assertSession()
->fieldNotExists('attributes[data-entity-embed-display-settings][alt]');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('Satanic leaf-tailed gecko title', $img
->getAttribute('title'));
$this
->assertEquals('default alt', $img
->getAttribute('alt'));
$field = FieldConfig::load('media.image.field_media_image');
$settings = $field
->getSettings();
$settings['alt_field'] = TRUE;
$settings['title_field'] = TRUE;
$field
->set('settings', $settings);
$field
->save();
drupal_flush_all_caches();
$this
->reopenDialog();
// Test that setting value to double quote will allow setting the alt
// and title to empty.
$alt
->setValue(MediaImageDecorator::EMPTY_STRING);
$title
->setValue(MediaImageDecorator::EMPTY_STRING);
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEmpty($img
->getAttribute('alt'));
$this
->assertEmpty($img
->getAttribute('title'));
$this
->reopenDialog();
// Test that *not* filling out the fields makes it fall back to the default.
$alt
->setValue('');
$title
->setValue('');
$this
->submitDialog();
$img = $this
->assertSession()
->elementExists('css', 'img');
$this
->assertEquals('default alt', $img
->getAttribute('alt'));
$this
->assertEquals('default title', $img
->getAttribute('title'));
}
/**
* Tests caption editing in the CKEditor widget.
*/
public function testCkeditorWidgetHasEditableCaption() {
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->pressEditorButton('test_media_entity_embed');
$this
->assertSession()
->waitForId('drupal-modal');
// Embed media.
$this
->assertSession()
->fieldExists('entity_id')
->setValue('Screaming hairy armadillo (1)');
$this
->assertSession()
->elementExists('css', 'button.js-button-next')
->click();
$this
->assertSession()
->waitForElementVisible('css', 'form.entity-embed-dialog-step--embed');
$this
->assertSession()
->selectExists('attributes[data-entity-embed-display]')
->setValue('entity_reference:media_thumbnail');
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->fieldExists('attributes[data-caption]')
->setValue('Is this the real life? Is this just fantasy?');
$this
->submitDialog();
// Assert that the embedded media was upcasted to a CKEditor widget.
$figcaption = $this
->assertSession()
->elementExists('css', 'figcaption');
$this
->assertTrue($figcaption
->hasAttribute('contenteditable'));
// Type in the widget's editable for the caption.
$this
->assertSession()
->waitForElement('css', 'figcaption');
$this
->setCaption('Caught in a <strong>landslide</strong>! No escape from <em>reality</em>!');
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementExists('css', 'figcaption > em');
$this
->assertSession()
->elementExists('css', 'figcaption > strong')
->click();
// Select the <strong> element and unbold it.
$this
->clickPathLinkByTitleAttribute("strong element");
$this
->pressEditorButton('bold');
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementExists('css', 'figcaption > em');
$this
->assertSession()
->elementNotExists('css', 'figcaption > strong');
// Select the <em> element and unitalicize it.
$this
->assertSession()
->elementExists('css', 'figcaption > em')
->click();
$this
->clickPathLinkByTitleAttribute("em element");
$this
->pressEditorButton('italic');
// The "source" button should reveal the HTML source in a state matching
// what is shown in the CKEditor widget.
$this
->pressEditorButton('source');
$source = $this
->assertSession()
->elementExists('css', 'textarea.cke_source');
$value = $source
->getValue();
$dom = Html::load($value);
$xpath = new \DOMXPath($dom);
$drupal_entity = $xpath
->query('//drupal-entity')[0];
$this
->assertEquals('Caught in a landslide! No escape from reality!', $drupal_entity
->getAttribute('data-caption'));
// Change the caption by modifying the HTML source directly. When exiting
// "source" mode, this should be respected.
$poor_boy_text = "I'm just a <strong>poor boy</strong>, I need no sympathy!";
$drupal_entity
->setAttribute("data-caption", $poor_boy_text);
$source
->setValue(Html::serialize($dom));
$this
->pressEditorButton('source');
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$figcaption = $this
->assertSession()
->waitForElement('css', 'figcaption');
$this
->assertEquals($poor_boy_text, $figcaption
->getHtml());
// Select the <strong> element that we just set in "source" mode. This
// proves that it was indeed rendered by the CKEditor widget.
$figcaption
->find('css', 'strong')
->click();
$this
->pressEditorButton('bold');
// Insert a link into the caption.
$this
->clickPathLinkByTitleAttribute("Caption element");
$this
->pressEditorButton('drupallink');
$this
->assertSession()
->waitForId('drupal-modal');
$this
->assertSession()
->waitForElementVisible('css', '#editor-link-dialog-form')
->findField('attributes[href]')
->setValue('https://www.drupal.org');
$this
->assertSession()
->elementExists('css', 'button.form-submit')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
// Wait for the live preview in the CKEditor widget to finish loading, then
// edit the link; no `data-cke-saved-href` attribute should exist on it.
$this
->getSession()
->switchToIFrame('ckeditor');
$figcaption = $this
->assertSession()
->waitForElement('css', 'figcaption');
$figcaption
->find('css', 'a')
->click();
$this
->clickPathLinkByTitleAttribute("a element");
$this
->pressEditorButton('drupallink');
$this
->assertSession()
->waitForId('drupal-modal');
$this
->assertSession()
->waitForElementVisible('css', '#editor-link-dialog-form')
->findField('attributes[href]')
->setValue('https://www.drupal.org/project/drupal');
$this
->assertSession()
->elementExists('css', 'button.form-submit')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->pressEditorButton('source');
$source = $this
->assertSession()
->elementExists('css', "textarea.cke_source");
$value = $source
->getValue();
$this
->assertStringContainsString('https://www.drupal.org/project/drupal', $value);
$this
->assertStringNotContainsString('data-cke-saved-href', $value);
// Save the entity.
$this
->assertSession()
->buttonExists('Save')
->press();
// Verify the saved entity when viewed also contains the captioned media.
$link = $this
->assertSession()
->elementExists('css', 'figcaption > a');
$this
->assertEquals('https://www.drupal.org/project/drupal', $link
->getAttribute('href'));
$this
->assertEquals("I'm just a poor boy, I need no sympathy!", $link
->getText());
// Edit it again, type a different caption in the widget.
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->waitForElementVisible('css', 'figcaption');
$this
->setCaption('Scaramouch, <em>Scaramouch</em>, will you do the <strong>Fandango</strong>?');
// Verify that the element path usefully indicates the specific media type
// that is being embedded.
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementExists('xpath', '//figcaption//em')
->click();
$this
->getSession()
->switchToIFrame();
$this
->assertSession()
->elementTextContains('css', '#cke_1_path', 'Embedded Media Entity Embed');
// Test that removing caption in the EntityEmbedDialog form sets the embed
// to be captionless.
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-caption]')
->setValue('');
$this
->submitDialog();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assertSession()
->elementExists('css', 'drupal-entity');
$this
->assertSession()
->elementNotExists('css', 'figcaption');
// Set a caption again; this time not using the CKEditor Widget, but through
// the dialog. We're typing HTML in the form field, but it will have to be
// HTML-encoded for it to actually show up properly in the CKEditor Widget.
$this
->reopenDialog();
$freddys_lament = "Mama, life had just begun. But now I've gone and <strong>thrown it all away</strong>! :(";
$this
->assertSession()
->fieldExists('attributes[data-caption]')
->setValue($freddys_lament);
$this
->submitDialog();
$this
->assertSession()
->elementExists('css', 'figcaption');
// Change the caption in the dialog to contain a link.
$wind_markup = '<a href="http://www.drupal.org">anyway the wind blows</a>';
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-caption]')
->setValue($wind_markup);
$this
->submitDialog();
// Assert the caption in the CKEditor widget was updated.
$figcaption = $this
->assertSession()
->waitForElementVisible('css', 'figcaption');
$this
->assertEquals('anyway the wind blows', $figcaption
->getText());
// Change the text of the link in the caption.
$gallileo = '<a href="http://www.drupal.org">Gallileo, figaro, magnifico</a>';
$this
->reopenDialog();
$this
->assertSession()
->fieldExists('attributes[data-caption]')
->setValue($gallileo);
$this
->submitDialog();
// Assert the caption in the CKEditor widget was updated.
$figcaption = $this
->assertSession()
->waitForElementVisible('css', 'figcaption');
$this
->assertEquals('Gallileo, figaro, magnifico', $figcaption
->getText());
// Erase the caption in the CKEditor Widget, verify the <figcaption> still
// exists and contains placeholder text, then type something else.
$this
->setCaption('');
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementContains('css', 'figcaption', '');
$this
->assertSession()
->elementAttributeContains('css', 'figcaption', 'data-placeholder', 'Enter caption here');
$this
->setCaption('Fin.');
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementContains('css', 'figcaption', 'Fin.');
}
/**
* Tests linkability of the CKEditor widget when `drupalimage` is disabled.
*/
public function testCkeditorWidgetIsLinkableWhenDrupalImageIsAbsent() {
// Remove the `drupalimage` plugin's `DrupalImage` button.
$editor = Editor::load('full_html');
$settings = $editor
->getSettings();
$rows = $settings['toolbar']['rows'];
foreach ($rows as $row_key => $row) {
foreach ($row as $group_key => $group) {
foreach ($group['items'] as $item_key => $item) {
if ($item === 'DrupalImage') {
unset($settings['toolbar']['rows'][$row_key][$group_key]['items'][$item_key]);
}
}
}
}
$editor
->setSettings($settings);
$editor
->save();
$this
->testCkeditorWidgetIsLinkable();
}
/**
* Tests linkability of the CKEditor widget.
*/
public function testCkeditorWidgetIsLinkable() {
$this->host->body->value = '<drupal-entity data-caption="baz" data-embed-button="test_media_entity_embed" data-entity-embed-display="entity_reference:media_thumbnail" data-entity-embed-display-settings="{"image_style":"","image_link":""}" data-entity-type="media" data-entity-uuid="' . $this->media
->uuid() . '"></drupal-entity>';
$this->host
->save();
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
// Select the CKEditor Widget and click the "link" button.
$drupal_entity = $this
->assertSession()
->waitForElementVisible('css', 'drupal-entity');
$this
->assertNotEmpty($drupal_entity);
$drupal_entity
->click();
$this
->pressEditorButton('drupallink');
$this
->assertSession()
->waitForId('drupal-modal');
// Enter a link in the link dialog and save.
$this
->assertSession()
->waitForElementVisible('css', '#editor-link-dialog-form')
->findField('attributes[href]')
->setValue('https://www.drupal.org');
$this
->assertSession()
->elementExists('css', 'button.form-submit')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
// Save the entity.
$this
->assertSession()
->buttonExists('Save')
->press();
// Verify the saved entity when viewed also contains the linked media.
$this
->assertSession()
->elementExists('css', 'figure > a[href="https://www.drupal.org"] > div[data-embed-button="test_media_entity_embed"] > img[src*="image-test.png"]');
// Test that `drupallink` also still works independently: inserting a link
// is possible.
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->pressEditorButton('drupallink');
$this
->assertSession()
->waitForId('drupal-modal');
$this
->assertSession()
->waitForElementVisible('css', '#editor-link-dialog-form')
->findField('attributes[href]')
->setValue('https://wikipedia.org');
$this
->assertSession()
->elementExists('css', 'button.form-submit')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->elementExists('css', 'body > a[href="https://wikipedia.org"]');
$this
->assertSession()
->elementExists('css', 'body > .cke_widget_drupalentity > drupal-entity > figure > a[href="https://www.drupal.org"]');
}
/**
* Tests that only <drupal-entity> tags are processed.
*
* @see \Drupal\Tests\entity_embed\Kernel\EntityEmbedFilterTest::testOnlyDrupalEntityTagProcessed()
*/
public function testOnlyDrupalEntityTagProcessed() {
$embed_code = '<drupal-entity data-caption="baz" data-embed-button="test_media_entity_embed" data-entity-embed-display="entity_reference:media_thumbnail" data-entity-embed-display-settings="{"image_style":"","image_link":""}" data-entity-type="media" data-entity-uuid="' . $this->media
->uuid() . '"></drupal-entity>';
$this->host->body->value = str_replace('drupal-entity', 'p', $embed_code);
$this->host
->save();
// Assert that `<p data-* …>` is not upcast into a CKEditor Widget.
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->waitForElementVisible('css', 'img[src*="example.jpg"]', 1000);
$this
->assertSession()
->elementNotExists('css', 'figure');
$this->host->body->value = $embed_code;
$this->host
->save();
// Assert that `<drupal-entity data-* …>` is upcast into a CKEditor Widget.
$this
->getSession()
->reload();
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->waitForElementVisible('css', 'img[src*="example.jpg"]');
$this
->assertSession()
->elementExists('css', 'figure');
}
/**
* The CKEditor Widget must load a preview generated using the default theme.
*/
public function testPreviewUsesDefaultThemeAndIsClientCacheable() {
// Make the node edit form use the admin theme, like on most Drupal sites.
$this
->config('node.settings')
->set('use_admin_theme', TRUE)
->save();
$this->container
->get('router.builder')
->rebuild();
// Allow the test user to view the admin theme.
$this->adminUser
->addRole($this
->drupalCreateRole([
'view the administration theme',
]));
$this->adminUser
->save();
// Configure a different default and admin theme, like on most Drupal sites.
$this
->config('system.theme')
->set('default', 'stable')
->set('admin', 'classy')
->save();
// Assert that when looking at an embedded entity in the CKEditor Widget,
// the preview is generated using the default theme, not the admin theme.
// @see entity_embed_test_entity_view_alter()
$this->host->body->value = '<drupal-entity data-caption="baz" data-embed-button="test_media_entity_embed" data-entity-embed-display="entity_reference:entity_reference_entity_view" data-entity-embed-display-settings="full" data-entity-type="media" data-entity-uuid="' . $this->media
->uuid() . '"></drupal-entity>';
$this->host
->save();
$this
->drupalGet($this->host
->toUrl('edit-form'));
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->waitForElementVisible('css', 'img[src*="image-test.png"]');
$element = $this
->assertSession()
->elementExists('css', '[data-entity-embed-test-active-theme]');
$this
->assertSame('stable', $element
->getAttribute('data-entity-embed-test-active-theme'));
// Assert that the first preview request transferred data over the wire.
// Then toggle source mode on and off. This causes the CKEditor widget to be
// destroyed and then reconstructed. Assert that during this reconstruction,
// a second request is sent. This second request should have transferred 0
// bytes: the browser should have cached the response, thus resulting in a
// much better user experience.
$this
->assertGreaterThan(0, $this
->getLastPreviewRequestTransferSize());
$this
->pressEditorButton('source');
$this
->assertSession()
->waitForElement('css', 'textarea.cke_source');
$this
->pressEditorButton('source');
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertSession()
->waitForElementVisible('css', 'img[src*="image-test.png"]');
$this
->assertSame(0, $this
->getLastPreviewRequestTransferSize());
}
/**
* Gets the transfer size of the last preview request.
*
* @return int
* The transfer size in octets.
*/
protected function getLastPreviewRequestTransferSize() {
$this
->getSession()
->switchToIFrame();
$javascript = <<<JS
(function(){
return window.performance
.getEntries()
.filter(function (entry) {
return entry.initiatorType == 'xmlhttprequest' && entry.name.indexOf('/entity-embed/preview/') !== -1;
})
.pop()
.transferSize;
})()
JS;
return $this
->getSession()
->evaluateScript($javascript);
}
/**
* Tests even <drupal-entity> elements whose button is not present are upcast.
*
* @param string $data_embed_button_attribute
* The HTML for a data-embed-button atttribute.
*
* @dataProvider providerCkeditorWidgetWorksForAllEmbeds
*/
public function testCkeditorWidgetWorksForAllEmbeds($data_embed_button_attribute) {
$this->host->body->value = '<drupal-entity data-caption="baz" ' . $data_embed_button_attribute . ' data-entity-embed-display="entity_reference:media_thumbnail" data-entity-embed-display-settings="{"image_style":"","image_link":""}" data-entity-type="media" data-entity-uuid="' . $this->media
->uuid() . '"></drupal-entity>';
$this->host
->save();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('node/' . $this->host
->id() . '/edit');
$this
->waitForEditor();
$this
->assignNameToCkeditorIframe();
$this
->getSession()
->switchToIFrame('ckeditor');
$this
->assertNotNull($this
->assertSession()
->waitForElementVisible('css', 'figcaption'));
}
/**
* Data provider for testCkeditorWidgetWorksForAllEmbeds().
*/
public function providerCkeditorWidgetWorksForAllEmbeds() {
return [
'present and active CKEditor button ID' => [
'data-embed-button="test_media_entity_embed"',
],
'present and inactive CKEditor button ID' => [
'data-embed-button="user"',
],
'present and nonsensical CKEditor button ID' => [
'data-embed-button="ceci nest pas une pipe"',
],
'absent' => [
'',
],
];
}
/**
* Helper function to submit dialog and focus on ckeditor frame.
*/
protected function submitDialog() {
$this
->assertSession()
->elementExists('css', 'button.button--primary')
->press();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->switchToIFrame('ckeditor');
}
/**
* Set the text of the editable caption to the given text.
*
* @param string $text
* The text to set in the caption.
*/
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);
}
/**
* Clicks a link in the editor's path links with the given title text.
*
* @param string $text
* The title attribute of the link to click.
*
* @throws \Behat\Mink\Exception\ElementNotFoundException
*/
protected function clickPathLinkByTitleAttribute($text) {
$this
->getSession()
->switchToIFrame();
$selector = '//span[@id="cke_1_path"]//a[@title="' . $text . '"]';
$this
->assertSession()
->elementExists('xpath', $selector)
->click();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was present in the last response. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is not present. | |
AssertLegacyTrait:: |
protected | function | Asserts that the element with the given CSS selector is present. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertLegacyTrait:: |
protected | function | Checks that current response header equals value. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertLegacyTrait:: |
protected | function | Asserts whether an expected cache tag was absent in the last response. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text is not found escaped on the loaded page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does NOT exist with the given name or ID. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertLegacyTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertLegacyTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertLegacyTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertLegacyTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option does NOT exist in the current page. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is not found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS not found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertLegacyTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertLegacyTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertLegacyTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | 1 |
AssertLegacyTrait:: |
protected | function | Asserts the page responds with the specified response code. | 1 |
AssertLegacyTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | 1 |
AssertLegacyTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertLegacyTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertLegacyTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertLegacyTrait:: |
protected | function | Passes if the internal browser's URL matches the given path. | |
AssertLegacyTrait:: |
protected | function | Builds an XPath query. | |
AssertLegacyTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertLegacyTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertLegacyTrait:: |
protected | function | Gets the current raw content. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
BlockCreationTrait:: |
protected | function | Creates a block instance based on default settings. Aliased as: drupalPlaceBlock | |
BrowserHtmlDebugTrait:: |
protected | property | The Base URI to use for links to the output files. | |
BrowserHtmlDebugTrait:: |
protected | property | Class name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Counter storage for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | Directory name for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output output enabled. | |
BrowserHtmlDebugTrait:: |
protected | property | The file name to write the list of URLs to. | |
BrowserHtmlDebugTrait:: |
protected | property | HTML output test ID. | |
BrowserHtmlDebugTrait:: |
protected | function | Formats HTTP headers as string for HTML output logging. | |
BrowserHtmlDebugTrait:: |
protected | function | Logs a HTML output message in a text file. | |
BrowserHtmlDebugTrait:: |
protected | function | Creates the directory to store browser output. | |
BrowserTestBase:: |
protected | property | The base URL. | |
BrowserTestBase:: |
protected | property | The config importer that can be used in a test. | |
BrowserTestBase:: |
protected | property | An array of custom translations suitable for drupal_rewrite_settings(). | |
BrowserTestBase:: |
protected | property | The database prefix of this test run. | |
BrowserTestBase:: |
protected | property | Mink session manager. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | The original container. | |
BrowserTestBase:: |
protected | property | The original array of shutdown function callbacks. | |
BrowserTestBase:: |
protected | property | ||
BrowserTestBase:: |
protected | property | The profile to install as a basis for testing. | 39 |
BrowserTestBase:: |
protected | property | The app root. | |
BrowserTestBase:: |
protected | property | Browser tests are run in separate processes to prevent collisions between code that may be loaded by tests. | |
BrowserTestBase:: |
protected | property | Time limit in seconds for the test. | |
BrowserTestBase:: |
protected | property | The translation file directory for the test environment. | |
BrowserTestBase:: |
protected | function | Clean up the Simpletest environment. | |
BrowserTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
BrowserTestBase:: |
protected | function | Translates a CSS expression to its XPath equivalent. | |
BrowserTestBase:: |
protected | function | Gets the value of an HTTP response header. | |
BrowserTestBase:: |
protected | function | Returns all response headers. | |
BrowserTestBase:: |
public static | function | Ensures test files are deletable. | |
BrowserTestBase:: |
protected | function | Gets an instance of the default Mink driver. | |
BrowserTestBase:: |
protected | function | Obtain the HTTP client for the system under test. | |
BrowserTestBase:: |
protected | function | Helper function to get the options of select field. | |
BrowserTestBase:: |
protected | function |
Provides a Guzzle middleware handler to log every response received. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
public | function | Returns Mink session. | |
BrowserTestBase:: |
protected | function | Get session cookies from current session. | |
BrowserTestBase:: |
protected | function |
Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait:: |
|
BrowserTestBase:: |
public | function | Installs Drupal into the Simpletest site. | 1 |
BrowserTestBase:: |
protected | function | Registers additional Mink sessions. | |
BrowserTestBase:: |
protected | function | Transforms a nested array into a flat array suitable for drupalPostForm(). | |
BrowserTestBase:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
BrowserTestBase:: |
public | function | 1 | |
BrowserTestBase:: |
public | function | Prevents serializing any properties. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. | 1 |
ContentTypeCreationTrait:: |
protected | function | Creates a custom content type based on default settings. Aliased as: drupalCreateContentType | 1 |
EntityEmbedTestBase:: |
protected | function | Assigns a name to the CKEditor iframe, to allow use of ::switchToIFrame(). | |
EntityEmbedTestBase:: |
protected | function | Clicks a CKEditor button. | |
EntityEmbedTestBase:: |
protected | function | Helper function to reopen EntityEmbedDialog for first embed. | |
EntityEmbedTestBase:: |
protected | function | Show visually hidden fields. | |
EntityEmbedTestBase:: |
protected | function | Waits for CKEditor to initialize. | |
FunctionalTestSetupTrait:: |
protected | property | The flag to set 'apcu_ensure_unique_prefix' setting. | 1 |
FunctionalTestSetupTrait:: |
protected | property | The class loader to use for installation and initialization of setup. | |
FunctionalTestSetupTrait:: |
protected | property | The config directories used in this test. | |
FunctionalTestSetupTrait:: |
protected | property | The "#1" admin user. | |
FunctionalTestSetupTrait:: |
protected | function | Execute the non-interactive installer. | 1 |
FunctionalTestSetupTrait:: |
protected | function | Returns all supported database driver installer objects. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize various configurations post-installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Initializes the kernel after installation. | |
FunctionalTestSetupTrait:: |
protected | function | Initialize settings created during install. | |
FunctionalTestSetupTrait:: |
protected | function | Initializes user 1 for the site to be installed. | |
FunctionalTestSetupTrait:: |
protected | function | Installs the default theme defined by `static::$defaultTheme` when needed. | |
FunctionalTestSetupTrait:: |
protected | function | Returns the parameters that will be used when Simpletest installs Drupal. | 9 |
FunctionalTestSetupTrait:: |
protected | function | Prepares the current environment for running the test. | 23 |
FunctionalTestSetupTrait:: |
protected | function | Creates a mock request and sets it on the generator. | |
FunctionalTestSetupTrait:: |
protected | function | Prepares site settings and services before installation. | 2 |
FunctionalTestSetupTrait:: |
protected | function | Resets and rebuilds the environment after setup. | |
FunctionalTestSetupTrait:: |
protected | function | Rebuilds \Drupal::getContainer(). | |
FunctionalTestSetupTrait:: |
protected | function | Resets all data structures after having enabled new modules. | |
FunctionalTestSetupTrait:: |
protected | function | Changes parameters in the services.yml file. | |
FunctionalTestSetupTrait:: |
protected | function | Sets up the base URL based upon the environment variable. | |
FunctionalTestSetupTrait:: |
protected | function | Rewrites the settings.php file of the test site. | |
MediaImageTest:: |
protected | property | The user to use during testing. | |
MediaImageTest:: |
protected | property |
The theme to install as the default for testing. Overrides EntityEmbedTestBase:: |
|
MediaImageTest:: |
protected | property | A host entity with a body field to embed media in. | |
MediaImageTest:: |
protected | property | The sample Media entity to embed. | |
MediaImageTest:: |
public static | property |
Modules to enable. Overrides EntityEmbedTestBase:: |
|
MediaImageTest:: |
protected | function | Clicks a link in the editor's path links with the given title text. | |
MediaImageTest:: |
protected | function | Gets the transfer size of the last preview request. | |
MediaImageTest:: |
public | function | Data provider for testCkeditorWidgetWorksForAllEmbeds(). | |
MediaImageTest:: |
protected | function | Set the text of the editable caption to the given text. | |
MediaImageTest:: |
protected | function |
Overrides BrowserTestBase:: |
|
MediaImageTest:: |
protected | function | Helper function to submit dialog and focus on ckeditor frame. | |
MediaImageTest:: |
public | function | Tests alt and title overriding for embedded images. | |
MediaImageTest:: |
public | function | Tests caption editing in the CKEditor widget. | |
MediaImageTest:: |
public | function | Tests linkability of the CKEditor widget. | |
MediaImageTest:: |
public | function | Tests linkability of the CKEditor widget when `drupalimage` is disabled. | |
MediaImageTest:: |
public | function | Tests even <drupal-entity> elements whose button is not present are upcast. | |
MediaImageTest:: |
public | function | Tests that only <drupal-entity> tags are processed. | |
MediaImageTest:: |
public | function | The CKEditor Widget must load a preview generated using the default theme. | |
NodeCreationTrait:: |
protected | function | Creates a node based on default settings. Aliased as: drupalCreateNode | |
NodeCreationTrait:: |
public | function | Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
RefreshVariablesTrait:: |
protected | function | Refreshes in-memory configuration and state information. | 3 |
SessionTestTrait:: |
protected | property | The name of the session cookie. | |
SessionTestTrait:: |
protected | function | Generates a session cookie name. | |
SessionTestTrait:: |
protected | function | Returns the session name in use on the child site. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestFileCreationTrait:: |
protected | property | Whether the files were copied to the test files directory. | |
TestFileCreationTrait:: |
protected | function | Compares two files based on size and file name. | |
TestFileCreationTrait:: |
public static | function | Generates a test file. | |
TestFileCreationTrait:: |
protected | function | Gets a list of files that can be used in tests. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. | |
TestSetupTrait:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
TestSetupTrait:: |
protected | property | The dependency injection container used in the test. | |
TestSetupTrait:: |
protected | property | The DrupalKernel instance used in the test. | |
TestSetupTrait:: |
protected | property | The site directory of the original parent site. | |
TestSetupTrait:: |
protected | property | The private file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The public file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The site directory of this test run. | |
TestSetupTrait:: |
protected | property | Set to TRUE to strict check all configuration saved. | 2 |
TestSetupTrait:: |
protected | property | The temporary file directory for the test environment. | |
TestSetupTrait:: |
protected | property | The test run ID. | |
TestSetupTrait:: |
protected | function | Changes the database connection to the prefixed one. | |
TestSetupTrait:: |
protected | function | Gets the config schema exclusions for this test. | |
TestSetupTrait:: |
public static | function | Returns the database connection to the site running Simpletest. | |
TestSetupTrait:: |
protected | function | Generates a database prefix for running tests. | 2 |
UiHelperTrait:: |
protected | property | The current user logged in using the Mink controlled browser. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects to follow, or NULL if unlimited. | |
UiHelperTrait:: |
protected | property | The number of meta refresh redirects followed during ::drupalGet(). | |
UiHelperTrait:: |
protected | function | Builds an a absolute URL from a system path or a URL object. | |
UiHelperTrait:: |
protected | function | Checks for meta refresh tag and if found call drupalGet() recursively. | |
UiHelperTrait:: |
protected | function | Clicks the element with the given CSS selector. | |
UiHelperTrait:: |
protected | function | Follows a link by complete name. | |
UiHelperTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
UiHelperTrait:: |
protected | function | Retrieves a Drupal path or an absolute path. | 3 |
UiHelperTrait:: |
protected | function | Logs in a user using the Mink controlled browser. | |
UiHelperTrait:: |
protected | function | Logs a user out of the Mink controlled browser and confirms. | |
UiHelperTrait:: |
protected | function | Executes a form submission. | |
UiHelperTrait:: |
protected | function | Returns whether a given user account is logged in. | |
UiHelperTrait:: |
protected | function | Takes a path and returns an absolute path. | |
UiHelperTrait:: |
protected | function | Retrieves the plain-text content from the current page. | |
UiHelperTrait:: |
protected | function | Get the current URL from the browser. | |
UiHelperTrait:: |
protected | function | Prepare for a request to testing site. | 1 |
UiHelperTrait:: |
protected | function | Fills and submits a form. | |
UserCreationTrait:: |
protected | function | Checks whether a given list of permission names is valid. | |
UserCreationTrait:: |
protected | function | Creates an administrative role. | |
UserCreationTrait:: |
protected | function | Creates a role with specified permissions. Aliased as: drupalCreateRole | |
UserCreationTrait:: |
protected | function | Create a user with a given set of permissions. Aliased as: drupalCreateUser | |
UserCreationTrait:: |
protected | function | Grant permissions to a user role. | |
UserCreationTrait:: |
protected | function | Switch the current logged in user. | |
UserCreationTrait:: |
protected | function | Creates a random user account and sets it as current user. | |
WebDriverTestBase:: |
protected | property | Disables CSS animations in tests for more reliable testing. | |
WebDriverTestBase:: |
protected | property |
To use a legacy phantomjs based approach, please use PhantomJSDriver::class. Overrides BrowserTestBase:: |
2 |
WebDriverTestBase:: |
protected | function | Asserts that the element with the given CSS selector is not visible. | |
WebDriverTestBase:: |
protected | function | Asserts that the element with the given CSS selector is visible. | |
WebDriverTestBase:: |
protected | function | Waits for the given time or until the given JS condition becomes TRUE. | |
WebDriverTestBase:: |
public | function |
Returns WebAssert object. Overrides UiHelperTrait:: |
1 |
WebDriverTestBase:: |
protected | function | Creates a screenshot. | |
WebDriverTestBase:: |
protected | function |
Gets the current Drupal javascript settings and parses into an array. Overrides BrowserTestBase:: |
|
WebDriverTestBase:: |
protected | function |
Returns headers in HTML output format. Overrides BrowserHtmlDebugTrait:: |
|
WebDriverTestBase:: |
protected | function |
Get the Mink driver args from an environment variable, if it is set. Can
be overridden in a derived class so it is possible to use a different
value for a subset of tests, e.g. the JavaScript tests. Overrides BrowserTestBase:: |
|
WebDriverTestBase:: |
protected | function |
Visits the front page when initializing Mink. Overrides BrowserTestBase:: |
|
WebDriverTestBase:: |
protected | function |
Initializes Mink sessions. Overrides BrowserTestBase:: |
1 |
WebDriverTestBase:: |
protected | function |
Install modules defined by `static::$modules`. Overrides FunctionalTestSetupTrait:: |
|
WebDriverTestBase:: |
protected | function |
Overrides BrowserTestBase:: |
1 |
XdebugRequestTrait:: |
protected | function | Adds xdebug cookies, from request setup. |