protected function MediaLibraryTestBase::openMediaLibraryForField in Drupal 9
Same name and namespace in other branches
- 8 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.
8 calls to MediaLibraryTestBase::openMediaLibraryForField()
- 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.
- WidgetOEmbedTest::testWidgetOEmbed in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ WidgetOEmbedTest.php - Tests that oEmbed media can be added in the Media library's widget.
- WidgetOEmbedTest::testWidgetOEmbedAdvancedUi in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ WidgetOEmbedTest.php - Tests that oEmbed media can be added in the widget's advanced UI.
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);
}