assertMediaAdded example

$this->waitForText('1 item selected');
    $this->pressInsertSelected('Added one media item.');
    $this->waitForText('Another video');

    // Assert removing an added oEmbed media item before save works as expected.     $this->openMediaLibraryForField('field_unlimited_media');
    $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 */
$path = $file_system->realpath($path);
      $this->assertNotEmpty($path);
      $this->assertFileExists($path);

      $filenames[] = $file_system->basename($path);
      $remote_paths[] = $this->getSession()
        ->getDriver()
        ->uploadFileAndGetRemoteFilePath($path);
    }
    $page = $this->getSession()->getPage();
    $page->fillField('Add files', implode("\n", $remote_paths));
    $this->assertMediaAdded();
    $assert_session = $this->assertSession();
    foreach ($filenames as $i => $filename) {
      $assert_session->fieldValueEquals("media[$i][fields][name][0][value]", $filename);
      $page->fillField("media[$i][fields][field_media_test_image][0][alt]", $filename);
    }
  }

  /** * Tests that the Media Library constrains the number of selected items. * * @param string|null $selected_operation * The operation of the button to click. For example, if this is "insert", * the "Save and insert" button will be pressed. If NULL, the "Save" button * will be pressed. * * @dataProvider providerWidgetOverflow */
// Add to the twin media field.     $this->openMediaLibraryForField('field_twin_media');

    // Assert the upload form is now visible for default tab type_three.     $assert_session->elementExists('css', '.js-media-library-add-form');
    $assert_session->fieldExists('Add files');

    // Assert we can upload a file to the default tab type_three.     $assert_session->elementNotExists('css', '.js-media-library-add-form[data-input]');
    $this->addMediaFileToField('Add files', $this->container->get('file_system')->realpath($png_image->uri));
    $this->assertMediaAdded();
    $assert_session->elementExists('css', '.js-media-library-add-form[data-input]');
    // We do not have pre-selected items, so the container should not be added     // to the form.     $assert_session->pageTextNotContains('Additional selected media');
    // Files are temporary until the form is saved.     $files = $file_storage->loadMultiple();
    $file = array_pop($files);
    $this->assertSame('public://type-three-dir', $file_system->dirname($file->getFileUri()));
    $this->assertTrue($file->isTemporary());
    // Assert the revision_log_message field is not shown.     $upload_form = $assert_session->elementExists('css', '.js-media-library-add-form');
    
Home | Imprint | This part of the site doesn't use cookies.