DropzoneContext.behat.inc in Lightning Media 8.3
File
tests/contexts/DropzoneContext.behat.inc
View source
<?php
namespace Acquia\LightningExtension\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\MinkExtension\Context\RawMinkContext;
use Drupal\DrupalDriverManager;
use Drupal\DrupalExtension\Context\DrupalSubContextInterface;
use Webmozart\Assert\Assert;
final class DropzoneContext extends RawMinkContext implements DrupalSubContextInterface {
public function __construct(DrupalDriverManager $drupal) {
}
public function uploadMultiple(PyStringNode $files) {
$page = $this
->getSession()
->getPage();
$this
->visitPath('/admin/content/media');
$page
->clickLink('Bulk upload');
sleep(3);
$files = $files
->getStrings();
foreach ($files as $file) {
$file = __DIR__ . '/../files/' . $file;
Assert::fileExists($file);
$session = $this
->getSession();
$session
->executeScript('Dropzone.instances[0].hiddenFileInput.name = "file"');
$page
->attachFileToField('file', $file);
sleep(3);
}
$page
->pressButton('Continue');
for ($i = 0; $i < count($files); $i++) {
$page
->pressButton('Save');
}
}
}
Classes
Name |
Description |
DropzoneContext |
Contains step definitions for interacting with DropzoneJS widgets. |