uploadFiles example

// If we want to press the "Save and insert" or "Save and select" buttons,     // we need to enable the advanced UI.     if ($selected_operation) {
      $this->config('media_library.settings')->set('advanced_ui', TRUE)->save();
    }

    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();
    $this->drupalGet('node/add/basic_page');
    // Upload 5 files into a media field that only allows 2.     $this->openMediaLibraryForField('field_twin_media');
    $this->uploadFiles(5);
    // Save the media items and ensure that the user is warned that they have     // selected too many items.     if ($selected_operation) {
      $this->saveAnd($selected_operation);
    }
    else {
      $this->pressSaveButton();
    }
    $this->waitForElementTextContains('.messages--warning', 'There are currently 5 items selected. The maximum number of items for the field is 2. Please remove 3 items from the selection.');
    // If the user tries to insert the selected items anyway, they should get     // an error.
Home | Imprint | This part of the site doesn't use cookies.