Summer Sale! All accounts are 50% off this week.

laracoft's avatar

UploadedFile from string when testing

I came across this https://gist.github.com/waska14/8b3bcebfad1f86f7fcd3b82927576e38 which converts a string into a Illuminate\Http\UploadedFile. However, it writes to the disk as part of the process and deletes it before terminating.

Is there a more direct way of doing this? Thank you.

0 likes
1 reply
laracoft's avatar
laracoft
OP
Best Answer
Level 27

UploadedFile::fake()->createWithContent('file.pdf', $content);

1 like

Please or to participate in this conversation.