DropzoneContext.behat.inc in Lightning Media 8.2
File
tests/contexts/DropzoneContext.behat.inc
View source
<?php
namespace Acquia\LightningExtension\Context;
use Behat\Gherkin\Node\PyStringNode;
use Drupal\DrupalExtension\Context\DrupalSubContextBase;
use Drupal\DrupalExtension\Context\MinkContext;
class DropzoneContext extends DrupalSubContextBase {
public function attachFileToDropzone($file) {
$this
->getSession()
->executeScript('Dropzone.instances[0].hiddenFileInput.name = "file"');
$this
->getContext(MinkContext::class)
->attachFileToField('file', $file);
sleep(3);
}
public function uploadMultiple(PyStringNode $files) {
$assert = $this
->assertSession();
$this
->visitPath('/admin/content/media');
$assert
->elementExists('named', [
'link',
'Bulk upload',
])
->click();
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();
}
}
}
Classes
Name |
Description |
DropzoneContext |
Contains step definitions for interacting with DropzoneJS widgets. |