Skip to content

Commit

Permalink
Merge pull request #119 from kbond/attach-file-bug
Browse files Browse the repository at this point in the history
fix: enable attaching `\SplFileInfo` objects
  • Loading branch information
kbond authored Feb 15, 2023
2 parents 90e99fc + 25c5ea5 commit 6843ca1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions tests/BrowserTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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"]')
;
Expand Down
2 changes: 1 addition & 1 deletion tests/PantherBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 6843ca1

Please sign in to comment.