Pesting form builder with upload file

I am trying to test upload the file in my order. That gives me an error foreach() argument must be of type array|object, string given. Here is my code.
Forms\Components\FileUpload::make('screenshot')
->required()
->label(__('Screenshot'))
->directory('transaction-images')
->columnSpanFull(),
Forms\Components\FileUpload::make('screenshot')
->required()
->label(__('Screenshot'))
->directory('transaction-images')
->columnSpanFull(),
test('user can order the product', function () {
$this->actingAs(User::factory()->create());

$file = Illuminate\Http\UploadedFile::fake()->create('screenshot.jpg');

livewire('order.create')
->fillForm([
'url' => fake()->url(),
'screenshot' => $file->name,
]);
});
test('user can order the product', function () {
$this->actingAs(User::factory()->create());

$file = Illuminate\Http\UploadedFile::fake()->create('screenshot.jpg');

livewire('order.create')
->fillForm([
'url' => fake()->url(),
'screenshot' => $file->name,
]);
});
No description
Solution:
It's working now. That does not belong with version breaks
Jump to solution
7 Replies
LeandroFerreira
LeandroFerreira7mo ago
I think it should be only $file Does it work without the file?
Shaung Bhone
Shaung BhoneOP7mo ago
No it's not I'll show you
LeandroFerreira
LeandroFerreira7mo ago
livewire('order.create') Shouldn't you pass the livewire component? Like livewire(CreateXX::class)
Shaung Bhone
Shaung BhoneOP7mo ago
no it's because I'm using volt here is error just $file
Trying to access array offset on null
Trying to access array offset on null
I'm using Class-based Volt components there is no app/livewire folder
Mark Chaney
Mark Chaney7mo ago
did you get this working? I think version 3.2.83 breaks single file uploads as it converts them all to an array regardless. My production code works and nothing changed but now the tests fail and its because of https://github.com/filamentphp/filament/commit/888701082d4ccc371d194041bbe53c4f4b9b00f1#diff-eab80cbdc04e95db87de932c13eb10bc20b8734a930ff88999fa3777e784971bR46
GitHub
Merge pull request #12940 from recca0120/fix/test-fake-uploaded-fil...
UploadedFile should be converted to TemporaryUploadedFile
Solution
Shaung Bhone
Shaung Bhone6mo ago
It's working now. That does not belong with version breaks
Want results from more Discord servers?
Add your server