assertNoMediaAdded example

// Assert the media item fields are shown and the vertical tabs are no     // longer shown.     $this->waitForFieldExists('Alternative text');
    $this->assertMediaAdded();
    // Press the 'Remove button' and assert the user is sent back to the media     // library.     $page->pressButton('media-0-remove-button');
    // Assert the remove message is shown.     $this->waitForText("The media item $png_image->filename has been removed.");
    // Assert the focus is shifted to the first tabbable element of the add     // form, which should be the source field.     $this->assertNoMediaAdded();
    $assert_session->elementExists('css', '.ui-dialog-titlebar-close')->click();

    // Assert uploading multiple files.     $this->openMediaLibraryForField('field_unlimited_media');
    $this->switchToMediaType('Three');
    // Assert the existing items are remembered when adding and removing media.     $checkbox = $page->findField("Select $existing_media_name");
    $checkbox->click();
    // Assert we can add multiple files.     $this->assertTrue($assert_session->fieldExists('Add files')->hasAttribute('multiple'));
    // Create a list of new files to upload.
$this->switchToMediaType('Five');
    $page->fillField('Add Type Five via URL', $youtube_url);
    $page->pressButton('Add');
    // Assert the media item fields are shown and the vertical tabs are no     // longer shown.     $this->assertMediaAdded();
    // Press the 'Remove button' and assert the user is sent back to the media     // library.     $page->pressButton('media-0-remove-button');
    // Assert the remove message is shown.     $this->waitForText("The media item $youtube_title has been removed.");
    $this->assertNoMediaAdded();
  }

  /** * Tests that oEmbed media can be added in the widget's advanced UI. * * @todo Merge this with testWidgetOEmbed() in * https://www.drupal.org/project/drupal/issues/3087227 */
  public function testWidgetOEmbedAdvancedUi() {
    $this->config('media_library.settings')->set('advanced_ui', TRUE)->save();

    
Home | Imprint | This part of the site doesn't use cookies.