#fileupload #test #pest
I have this FileUpload field:
and this test:
However, the test fails as the model retains the old filename. Has anyone solved this before?
Solution:Jump to solution
So with a little assistance from Copilot, I was able to get it working using the ->set() method.
```php
livewire(EditRecipe::class, ['record' => $recipe->getRouteKey()])
->fillForm([
'title' => $recipe->title,...
4 Replies
This is how I test for edit with file upload
I didn't think to use dot notation on the image field. Unfortunately, this only works me if the resources doesn't have an existing image attached to it. Does your test still work if you assign an initial image to the
$blog
? Mine retains the original image path and won't save the path to the new one. (Although the file itself is being created).My BlogFactory have fake()->imagepath() ? so i only test like this..
Solution
So with a little assistance from Copilot, I was able to get it working using the ->set() method.