Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

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? (31 h 16 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…