From d03de6aeb356e720b20ab3f0f5275c5bea6ae38f Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Wed, 15 Feb 2023 16:50:09 -0500 Subject: [PATCH 1/3] fix: enable attaching `\SplFileInfo` objects It was not possible to attach an `\SplFileInfo` object as it was cast to an array. Adding the `string|array` type-hint fixes this. --- src/Browser.php | 4 ++-- tests/BrowserTests.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Browser.php b/src/Browser.php index 1812456..2789a52 100644 --- a/src/Browser.php +++ b/src/Browser.php @@ -286,12 +286,12 @@ final public function selectFieldOptions(string $selector, array $values): self } /** - * @param string[]|string $filename string: single file + * @param string|string[] $filename string: single file * array: multiple files * * @return static */ - final public function attachFile(string $selector, $filename): self + final public function attachFile(string $selector, array|string $filename): self { foreach ((array) $filename as $file) { if (!\file_exists($file)) { diff --git a/tests/BrowserTests.php b/tests/BrowserTests.php index 63985f8..a284ea3 100644 --- a/tests/BrowserTests.php +++ b/tests/BrowserTests.php @@ -366,7 +366,7 @@ public function form_actions_by_field_label(): void ->checkField('Input 2') ->uncheckField('Input 3') ->selectFieldOption('Input 4', 'option 2') - ->attachFile('Input 5', __FILE__) + ->attachFile('Input 5', new \SplFileInfo(__FILE__)) ->selectFieldOptions('Input 6', ['option 1', 'option 3']) ->checkField('Radio 3') ->click('Submit') @@ -547,7 +547,7 @@ public function can_attach_multiple_files(): void { $this->browser() ->visit('/page1') - ->attachFile('Input 9', [__DIR__.'/Fixture/files/attachment.txt', __DIR__.'/Fixture/files/xml.xml']) + ->attachFile('Input 9', [__DIR__.'/Fixture/files/attachment.txt', new \SplFileInfo(__DIR__.'/Fixture/files/xml.xml')]) ->click('Submit') ->assertContains('"input_9":["attachment.txt","xml.xml"]') ; From ab4b54865c34b4077e10c27b46ac1d9ad38e174c Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Wed, 15 Feb 2023 16:52:48 -0500 Subject: [PATCH 2/3] fix(ci): don't run fixcs/sync-with-template on forks --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11ac2bf..412b9a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: fixcs: name: Run php-cs-fixer needs: sync-with-template - if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags') + if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags') && github.repository_owner == 'zenstruck' runs-on: ubuntu-latest steps: - uses: zenstruck/.github@php-cs-fixer @@ -33,7 +33,7 @@ jobs: sync-with-template: name: Sync meta files - if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags') + if: (github.event_name == 'push' || github.event_name == 'schedule') && !startsWith(github.ref, 'refs/tags') && github.repository_owner == 'zenstruck' runs-on: ubuntu-latest steps: - uses: zenstruck/.github@sync-with-template From 25c5ea5098e764a95aeb18e07404dd71077c3f08 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Wed, 15 Feb 2023 16:53:14 -0500 Subject: [PATCH 3/3] fix(tests): deprecation --- tests/PantherBrowserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PantherBrowserTest.php b/tests/PantherBrowserTest.php index 7d2f14c..3a79c11 100644 --- a/tests/PantherBrowserTest.php +++ b/tests/PantherBrowserTest.php @@ -189,7 +189,7 @@ public function can_dump_console_log_with_throw_error(): void public function cannot_follow_invisible_link(): void { $this->expectException(AssertionFailedError::class); - $this->expectErrorMessage('Clickable element "invisible link" is not visible.'); + $this->expectExceptionMessage('Clickable element "invisible link" is not visible.'); $this->browser() ->visit('/javascript')