From fb0385ce527260097fb6638eafca3c06c65721fb Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 24 Jul 2024 16:56:01 +0100 Subject: [PATCH 1/5] Test file uploads properly --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ec66cc6c..9b095a49 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -87,7 +87,7 @@ jobs: - name: Start Selenium run: | - docker run --net host --name selenium --volume /dev/shm:/dev/shm --volume $GITHUB_WORKSPACE:$GITHUB_WORKSPACE -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g ${{ matrix.selenium.image }} &> ./logs/selenium.log & + docker run --net host --name selenium --volume /dev/shm:/dev/shm -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g ${{ matrix.selenium.image }} &> ./logs/selenium.log & - name: Wait for browser & PHP to start run: | From f08e03b5f0f4b989567d32cb434bf448b4b2598a Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 24 Jul 2024 17:23:42 +0100 Subject: [PATCH 2/5] Revert "Test file uploads properly" This reverts commit fb0385ce527260097fb6638eafca3c06c65721fb. --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b095a49..ec66cc6c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -87,7 +87,7 @@ jobs: - name: Start Selenium run: | - docker run --net host --name selenium --volume /dev/shm:/dev/shm -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g ${{ matrix.selenium.image }} &> ./logs/selenium.log & + docker run --net host --name selenium --volume /dev/shm:/dev/shm --volume $GITHUB_WORKSPACE:$GITHUB_WORKSPACE -e SE_NODE_OVERRIDE_MAX_SESSIONS=true -e SE_NODE_MAX_SESSIONS=5 --shm-size 2g ${{ matrix.selenium.image }} &> ./logs/selenium.log & - name: Wait for browser & PHP to start run: | From 50a1dcb18290d5c8efb0d4ed904677e49c7e6013 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 24 Jul 2024 17:45:22 +0100 Subject: [PATCH 3/5] Add a test for remote files --- tests/Custom/RemoteFileUploadTest.php | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/Custom/RemoteFileUploadTest.php diff --git a/tests/Custom/RemoteFileUploadTest.php b/tests/Custom/RemoteFileUploadTest.php new file mode 100644 index 00000000..c7430675 --- /dev/null +++ b/tests/Custom/RemoteFileUploadTest.php @@ -0,0 +1,47 @@ +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'); + $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'); + } + } + +} From cdeb3f043815beea8556181ca796303c453af713 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Wed, 24 Jul 2024 17:51:12 +0100 Subject: [PATCH 4/5] Fix static analysis --- tests/Custom/RemoteFileUploadTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Custom/RemoteFileUploadTest.php b/tests/Custom/RemoteFileUploadTest.php index c7430675..23f845ac 100644 --- a/tests/Custom/RemoteFileUploadTest.php +++ b/tests/Custom/RemoteFileUploadTest.php @@ -23,6 +23,7 @@ public function testRemoteFileUpload(): void 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"')) { From 58e70d96b6fff0a41593171e86ee3ad9a55c5fe0 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 5 Aug 2024 21:56:56 +0100 Subject: [PATCH 5/5] Up the php-webdriver constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",