diff --git a/core/modules/image/tests/src/FunctionalJavascript/ImageFieldWidgetMultipleTest.php b/core/modules/image/tests/src/FunctionalJavascript/ImageFieldWidgetMultipleTest.php index 84c1a1a05b..759f9d8a4f 100644 --- a/core/modules/image/tests/src/FunctionalJavascript/ImageFieldWidgetMultipleTest.php +++ b/core/modules/image/tests/src/FunctionalJavascript/ImageFieldWidgetMultipleTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\image\FunctionalJavascript; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\node\Entity\Node; use Drupal\Tests\image\Kernel\ImageFieldCreationTrait; @@ -22,16 +21,7 @@ class ImageFieldWidgetMultipleTest extends WebDriverTestBase { /** * {@inheritdoc} */ - protected $minkDefaultDriverClass = DrupalSelenium2Driver::class; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'node', - 'field_ui', - 'image', - ]; + protected static $modules = ['node', 'field_ui', 'image']; /** * Tests image widget element support multiple upload correctly. @@ -39,6 +29,7 @@ class ImageFieldWidgetMultipleTest extends WebDriverTestBase { public function testWidgetElementMultipleUploads() { $image_factory = \Drupal::service('image.factory'); $file_system = \Drupal::service('file_system'); + $web_driver = $this->getSession()->getDriver(); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); $field_name = 'images'; @@ -59,7 +50,7 @@ public function testWidgetElementMultipleUploads() { $remote_paths = []; foreach ($paths as $path) { - $remote_paths[] = $this->uploadFileRemotePath($path); + $remote_paths[] = $web_driver->uploadFileAndGetRemoteFilePath($path); } $multiple_field = $this->xpath('//input[@multiple]')[0]; @@ -76,28 +67,4 @@ public function testWidgetElementMultipleUploads() { } } - /** - * Uploads a file to the Selenium instance for get remote path. - * - * Copied from \Behat\Mink\Driver\Selenium2Driver::uploadFile(). - * - * @param string $path - * The path to the file to upload. - * - * @return string - * The remote path. - * - * @todo: Remove after https://www.drupal.org/project/drupal/issues/2947517. - */ - protected function uploadFileRemotePath($path) { - $tempFilename = tempnam('', 'WebDriverZip'); - $archive = new \ZipArchive(); - $archive->open($tempFilename, \ZipArchive::CREATE); - $archive->addFile($path, basename($path)); - $archive->close(); - $remotePath = $this->getSession()->getDriver()->getWebDriverSession()->file(['file' => base64_encode(file_get_contents($tempFilename))]); - unlink($tempFilename); - return $remotePath; - } - }