Skip to content

[8.x] Fix assertDownload if testing against a filename with spaces in it - #39536

Merged
taylorotwell merged 2 commits into
laravel:8.xfrom
defstudio:fix-assert-download
Nov 8, 2021
Merged

[8.x] Fix assertDownload if testing against a filename with spaces in it#39536
taylorotwell merged 2 commits into
laravel:8.xfrom
defstudio:fix-assert-download

Conversation

@fabio-ivona

@fabio-ivona fabio-ivona commented Nov 8, 2021

Copy link
Copy Markdown
Contributor

This PR will fix an unexpected assertion failures when trying to check a TestResponse download filename:

let's suppose we are testing a method that returns a storage download:

Storage::download('file.txt', 'test file.txt');

the generated StreamedResponse will have this header:

content-disposition: attachment; filename="test file.txt"

as TestResponse checks ->assertDownload('test file.txt') against that header, it will trow a failure because

test file.txt != "test file.txt"

the only way I found to make this to pass is to check ->assertDownload('"test file.txt"')

My PR aims to fix this by adding a quotes trimming to the assertion

@GrahamCampbell GrahamCampbell changed the title Fix assertDownload if testing against a filename with spaces in it [8.x] Fix assertDownload if testing against a filename with spaces in it Nov 8, 2021
@taylorotwell
taylorotwell merged commit 8e2d727 into laravel:8.x Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants