protected function MediaLibraryTestBase::assertMediaAdded 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::assertMediaAdded()
Asserts a media item was added, but not yet saved.
Parameters
int $index: (optional) The index of the media item, if multiple items can be added at once. Defaults to 0.
4 calls to MediaLibraryTestBase::assertMediaAdded()
- 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.
- WidgetUploadTest::testWidgetUploadAdvancedUi in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ WidgetUploadTest.php - Tests that uploads in the widget's advanced UI works as expected.
File
- core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ MediaLibraryTestBase.php, line 318
Class
- MediaLibraryTestBase
- Base class for functional tests of Media Library functionality.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
protected function assertMediaAdded($index = 0) {
$selector = '.js-media-library-add-form-added-media';
// Assert that focus is shifted to the new media items.
$this
->assertJsCondition('jQuery("' . $selector . '").is(":focus")');
$assert_session = $this
->assertSession();
$assert_session
->pageTextMatches('/The media items? ha(s|ve) been created but ha(s|ve) not yet been saved. Fill in any required fields and save to add (it|them) to the media library./');
$assert_session
->elementAttributeContains('css', $selector, 'aria-label', 'Added media items');
$fields = $this
->assertElementExistsAfterWait('css', '[data-drupal-selector="edit-media-' . $index . '-fields"]');
$assert_session
->elementNotExists('css', '.js-media-library-menu');
// Assert extraneous components were removed in
// FileUploadForm::hideExtraSourceFieldComponents().
$assert_session
->elementNotExists('css', '[data-drupal-selector$="preview"]', $fields);
$assert_session
->buttonNotExists('Remove', $fields);
$assert_session
->elementNotExists('css', '[data-drupal-selector$="filename"]', $fields);
$assert_session
->elementNotExists('css', '.file-size', $fields);
}