diff --git a/composer.json b/composer.json index 77d2a6e3..37b10697 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": ">=8.1", "ext-json": "*", "behat/mink": "^1.11@dev", - "lullabot/php-webdriver": "^2.0.5" + "lullabot/php-webdriver": "^2.0.6" }, "require-dev": { "mink/driver-testsuite": "dev-master", diff --git a/tests/Custom/RemoteFileUploadTest.php b/tests/Custom/RemoteFileUploadTest.php new file mode 100644 index 00000000..23f845ac --- /dev/null +++ b/tests/Custom/RemoteFileUploadTest.php @@ -0,0 +1,48 @@ +getSession()->visit($this->pathTo('/advanced_form.html')); + + $webAssert = $this->getAssertSession(); + $page = $this->getSession()->getPage(); + + $about = $webAssert->fieldExists('about'); + // Place a file outside of the directories mapped to the selenium + // server. + $path = sys_get_temp_dir() . '/some_file.txt'; + copy(InstalledVersions::getInstallPath('mink/driver-testsuite') . '/web-fixtures/some_file.txt', $path); + $about->attachFile($path); + unlink(sys_get_temp_dir() . '/some_file.txt'); + + $button = $page->findButton('Register'); + $this->assertNotNull($button); + $button->press(); + + if ($this->safePageWait(5000, 'document.title === "Advanced form save"')) { + $out = <<<'OUT' +some_file.txt +1 uploaded file +OUT; + $this->assertStringContainsString($out, $page->getContent()); + } + else { + $this->fail('Failed to submit form'); + } + } + + protected function tearDown(): void + { + if (file_exists(sys_get_temp_dir() . '/some_file.txt')) { + unlink(sys_get_temp_dir() . '/some_file.txt'); + } + } + +}