Laravel 5.6 Testing File Uploads (Unable to find a file at path [file.txt]) Laravel 5.6 Testing File Uploads (Unable to find a file at path [file.txt]) php php

Laravel 5.6 Testing File Uploads (Unable to find a file at path [file.txt])


With Storage::fake('files') you would fake a so called disk named 'files'. In your filesystems.php is no disk declared named 'files'.

In your FileUploadController you are saving to the subdirectory 'files' on your 'local' disk, so for making your test work, just fake this disk:

Storage::fake('local');

Also use this disk then for the assertions:

Storage::disk('local')->assertExists('files/' . $fileName);

In the testing environment the path will be storage/framework/testing/disks and not below storage/app directly.