You are here

protected function MediaLibraryTestBase::openMediaLibraryForField in Drupal 8

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. 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.

7 calls to MediaLibraryTestBase::openMediaLibraryForField()
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.
WidgetUploadTest::testWidgetUpload in core/modules/media_library/tests/src/FunctionalJavascript/WidgetUploadTest.php
Tests that uploads in the Media library's widget works as expected.

... 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);
}