public function DropzoneJsElementTest::testDropzoneJsElement in DropzoneJS 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/DropzoneJsElementTest.php \Drupal\Tests\dropzonejs\Kernel\DropzoneJsElementTest::testDropzoneJsElement()
Tests that the dropzonejs element appears.
File
- tests/
src/ Kernel/ DropzoneJsElementTest.php, line 45
Class
- DropzoneJsElementTest
- Tests related to the DropzoneJS element.
Namespace
Drupal\Tests\dropzonejs\KernelCode
public function testDropzoneJsElement() {
$this->container
->get('router.builder')
->rebuild();
$form = \Drupal::formBuilder()
->getForm('\\Drupal\\dropzonejs_test\\Form\\DropzoneJsTestForm');
$this
->render($form);
$xpath_base = "//div[contains(@class, 'form-item-dropzonejs')]";
// Label.
$this
->assertEmpty($this
->xpath("{$xpath_base}/label[text()='Not DropzoneJS element']"));
$this
->assertNotEmpty($this
->xpath("{$xpath_base}/label[text()='DropzoneJS element']"));
// Element where dropzonejs is attached to.
$this
->assertNotEmpty($this
->xpath("{$xpath_base}/div[contains(@class, 'dropzone-enable')]"));
// Uploaded files input.
$this
->assertNotEmpty($this
->xpath("{$xpath_base}/input[contains(@data-drupal-selector, 'edit-dropzonejs-uploaded-files')]"));
// Upload files path.
$this
->assertNotEmpty($this
->xpath("{$xpath_base}/input[contains(@data-upload-path, '/dropzonejs/upload?token=')]"));
// Js is attached.
$this
->assertNotEmpty($this
->xpath("/html/body/script[contains(@src, 'libraries/dropzone/dist/min/dropzone.min.js')]"));
$this
->assertNotEmpty($this
->xpath("/html/body/script[contains(@src, 'dropzonejs/js/dropzone.integration.js')]"));
}