Skip to main content

Asserting File Downloads

Premium
2 min read

This short lesson is about a rarely used assertion for file downloads.


In the Controller, you have a method where the response is to download a file.

use Symfony\Component\HttpFoundation\BinaryFileResponse;
 
class ProductController extends Controller
{
// ...
 
public function download(): BinaryFileResponse
{
return response()->download(storage_path('files/product-specification.pdf'));
}
}

How can you test if this download was successful and if the download returned that exact file name to the browser?

In the test, you can assert the...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 33 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.