protected function MediaLibraryTestBase::openMediaLibraryForField in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::openMediaLibraryForField()
- 9 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.
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\FunctionalJavascriptCode
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);
}