X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fentity_browser%2Ftests%2Fsrc%2FFunctionalJavascript%2FUploadWidgetTest.php;fp=web%2Fmodules%2Fcontrib%2Fentity_browser%2Ftests%2Fsrc%2FFunctionalJavascript%2FUploadWidgetTest.php;h=b7bf839328f5b96cb0abc24c66433a4fa8c6ac72;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/entity_browser/tests/src/FunctionalJavascript/UploadWidgetTest.php b/web/modules/contrib/entity_browser/tests/src/FunctionalJavascript/UploadWidgetTest.php new file mode 100644 index 000000000..b7bf83932 --- /dev/null +++ b/web/modules/contrib/entity_browser/tests/src/FunctionalJavascript/UploadWidgetTest.php @@ -0,0 +1,73 @@ +grantPermissions($role, ['access test_entity_browser_standalone_upload entity browser pages']); + + } + + /** + * Tests Entity Browser upload widget. + */ + public function testUploadWidget() { + + /** @var \Drupal\entity_browser\EntityBrowserInterface $browser */ + $browser = $this->container->get('entity_type.manager') + ->getStorage('entity_browser') + ->load('test_entity_browser_standalone_upload'); + + $page = $this->getSession()->getPage(); + + // Make sure the test file is not present beforehand. + $this->assertFileNotExists('public://druplicon.png'); + + // Go to the widget standalone page and test the upload. + $this->drupalGet($browser->getDisplay()->path()); + $page->attachFileToField('edit-upload-upload', \Drupal::root() . '/core/misc/druplicon.png'); + $this->waitForAjaxToFinish(); + $this->assertSession()->fieldExists('druplicon.png'); + $page->pressButton('Select files'); + $this->assertSession()->statusCodeEquals(200); + + // Check if the file was correctly uploaded to the EB destination. + $this->assertFileExists('public://druplicon.png'); + + // Now change upload location and submit label and check again. + $widget = $browser->getWidget('2dc1ab07-2f8f-42c9-aab7-7eef7f8b7d87'); + $config = $widget->getConfiguration(); + $config['settings']['upload_location'] = 'public://some_location'; + $config['settings']['submit_text'] = 'Fancy submit'; + $widget->setConfiguration($config); + $browser->save(); + + $this->drupalGet($browser->getDisplay()->path()); + $page->attachFileToField('edit-upload-upload', \Drupal::root() . '/core/misc/druplicon.png'); + $this->waitForAjaxToFinish(); + $this->assertSession()->fieldExists('druplicon.png'); + $page->pressButton('Fancy submit'); + $this->assertSession()->statusCodeEquals(200); + + // Check if the file was correctly uploaded to the EB destination. + $this->assertFileExists('public://some_location/druplicon.png'); + + } + +}