function MediaLibraryTestBase::openMediaLibraryForField

Same name and namespace in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()
  2. 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()
  3. 10 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()

Clicks a button that opens a media widget and confirms it is open.

Parameters

string $field_name: The machine name of the field for which to open the media library.

string $after_open_selector: The selector to look for after the button is clicked.

Return value

\Behat\Mink\Element\NodeElement The NodeElement found via $after_open_selector.

13 calls to MediaLibraryTestBase::openMediaLibraryForField()
ClaroModalDisplayTest::testModalAddAnother in core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroModalDisplayTest.php
Tests the position f "add another" button in dialogs.
EntityReferenceWidgetTest::testAddAfterReordering in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests that order is correct after re-order and adding another item.
EntityReferenceWidgetTest::testRemoveAfterReordering in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests that changed order is maintained after removing a selection.
EntityReferenceWidgetTest::testRequiredMediaField in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests saving a required media library field.
EntityReferenceWidgetTest::testWidget in core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php
Tests that the Media library's widget works as expected.

... See full list

File

core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php, line 278

Class

MediaLibraryTestBase
Base class for functional tests of Media Library functionality.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function openMediaLibraryForField($field_name, $after_open_selector = '.js-media-library-menu') {
    $this->assertElementExistsAfterWait('css', "#{$field_name}-media-library-wrapper.js-media-library-widget")
        ->pressButton('Add media');
    $this->waitForText('Add or select media');
    // Assert that the grid display is visible and the links to toggle between
    // the grid and table displays are present.
    $this->assertMediaLibraryGrid();
    $assert_session = $this->assertSession();
    $assert_session->linkExists('Grid');
    $assert_session->linkExists('Table');
    // The "select all" checkbox should never be present in the modal.
    $assert_session->elementNotExists('css', '.media-library-select-all');
    return $this->assertElementExistsAfterWait('css', $after_open_selector);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.