function MediaLibraryTestBase::openMediaLibraryForField

Same name in other branches
  1. 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()
  2. 10 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()
  3. 11.x 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.

10 calls to MediaLibraryTestBase::openMediaLibraryForField()
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.
WidgetAnonymousTest::testWidgetAnonymous in core/modules/media_library/tests/src/FunctionalJavascript/WidgetAnonymousTest.php
Tests that the widget works as expected for anonymous users.

... See full list

File

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

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.