You are here

public function DropzoneContext::uploadMultiple in Lightning Media 8.2

Same name and namespace in other branches
  1. 8.3 tests/contexts/DropzoneContext.behat.inc \Acquia\LightningExtension\Context\DropzoneContext::uploadMultiple()

Uploads multiple files into the media library using Dropzone.

@When I upload the following files:

Parameters

\Behat\Gherkin\Node\PyStringNode $files:

File

tests/contexts/DropzoneContext.behat.inc, line 44

Class

DropzoneContext
Contains step definitions for interacting with DropzoneJS widgets.

Namespace

Acquia\LightningExtension\Context

Code

public function uploadMultiple(PyStringNode $files) {
  $assert = $this
    ->assertSession();
  $this
    ->visitPath('/admin/content/media');
  $assert
    ->elementExists('named', [
    'link',
    'Bulk upload',
  ])
    ->click();

  // Wait for the dropzone to be initialized.
  sleep(3);
  $files = $files
    ->getStrings();
  foreach ($files as $file) {
    $this
      ->attachFileToDropzone($file);
  }
  $assert
    ->elementExists('named', [
    'button',
    'Continue',
  ])
    ->press();
  for ($i = 0; $i < count($files); $i++) {
    $assert
      ->elementExists('named', [
      'button',
      'Save',
    ])
      ->press();
  }
}