I am testing that a file is remove after a response download as below:
UploadedFile::fake()
->create('test-file.xlsx')
->storeAs("{$dataset->id}", 'test-excel-file.xlsx'.,'datasets');
$this->get(route('datasets.export', ['dataset' => $dataset->id, 'hash' => 'test-excel-file']))
->assertHeader('Content-Type', 'excel.mime'))
->assertHeader('Content-Disposition', "attachment; filename=downloadFileName");
Storage::disk('datasets')->assertMissing("{$dataset->id}/test-excel-file.xlsx");
the code for the response is the following:
return response()->download(
$dataset->filePath(),
'downloadFileName',
[
'Content-Type' => 'excel.mime',
'Cache-Control' => 'cache, must-revalidate',
]
)->deleteFileAfterSend(true);
i am getting this error:
Tests\Feature\SendExportGeneratedEmailTest::it_downloads_the_dataset_file
Found unexpected file at path [1/test-excel-file.xlsx].
Failed asserting that true is false.
Every assertion works except the assertMissing. The file is not being deleted, but when tested in the browser it works
hope anyone can help
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community