Call actions in test

How do I call 'mutateFormDataBeforeFill' in test file? Test:
it('can retrieve accurate edit data', function () {
$record = Transaction::first() ?? Transaction::factory()->create();

livewire(EditTransaction::class, [
'record' => $record->getRouteKey(),
])
->callAction('mutateFormDataBeforeFill', $record->toArray())
->assertFormSet($record->toArray());
});
it('can retrieve accurate edit data', function () {
$record = Transaction::first() ?? Transaction::factory()->create();

livewire(EditTransaction::class, [
'record' => $record->getRouteKey(),
])
->callAction('mutateFormDataBeforeFill', $record->toArray())
->assertFormSet($record->toArray());
});
EditTransaction.php:
protected function mutateFormDataBeforeFill(array $data): array
{
$restCust = RestaurantCustomer::find($data['restaurant_customer_id']);
$data['restaurant_id'] = $restCust->restaurant->name;
$data['customer_id'] = $restCust->user->name;
$data['point_id'] = Point::find($data['point_id'])->points;

return $data;
}
protected function mutateFormDataBeforeFill(array $data): array
{
$restCust = RestaurantCustomer::find($data['restaurant_customer_id']);
$data['restaurant_id'] = $restCust->restaurant->name;
$data['customer_id'] = $restCust->user->name;
$data['point_id'] = Point::find($data['point_id'])->points;

return $data;
}
Error:
FAILED Tests\Feature\Admin\ATransaction\EditTransactionTest > it can retrieve accurate edit data ArgumentCountError
Too few arguments to function App\Filament\Resources\TransactionResource\Pages\EditTransaction::mutateFormDataBeforeFill(), 0 passed in C:\Users\JiaYong\Documents\GitHub\food-partner\vendor\filament\actions\src\Concerns\InteractsWithActions.php on line 308 and exactly 1 expected

at app\Filament\Resources\TransactionResource\Pages\EditTransaction.php:23
19▕ Actions\DeleteAction::make(),
20▕ ];
21▕ }
22▕
➜ 23▕ protected function mutateFormDataBeforeFill(array $data): array
24▕ {
25▕ $restCust = RestaurantCustomer::find($data['restaurant_customer_id']);
26▕ $data['restaurant_id'] = $restCust->restaurant->name;
27▕ $data['customer_id'] = $restCust->user->name;

1 app\Filament\Resources\TransactionResource\Pages\EditTransaction.php:23
2 vendor\filament\actions\src\Concerns\InteractsWithActions.php:308
FAILED Tests\Feature\Admin\ATransaction\EditTransactionTest > it can retrieve accurate edit data ArgumentCountError
Too few arguments to function App\Filament\Resources\TransactionResource\Pages\EditTransaction::mutateFormDataBeforeFill(), 0 passed in C:\Users\JiaYong\Documents\GitHub\food-partner\vendor\filament\actions\src\Concerns\InteractsWithActions.php on line 308 and exactly 1 expected

at app\Filament\Resources\TransactionResource\Pages\EditTransaction.php:23
19▕ Actions\DeleteAction::make(),
20▕ ];
21▕ }
22▕
➜ 23▕ protected function mutateFormDataBeforeFill(array $data): array
24▕ {
25▕ $restCust = RestaurantCustomer::find($data['restaurant_customer_id']);
26▕ $data['restaurant_id'] = $restCust->restaurant->name;
27▕ $data['customer_id'] = $restCust->user->name;

1 app\Filament\Resources\TransactionResource\Pages\EditTransaction.php:23
2 vendor\filament\actions\src\Concerns\InteractsWithActions.php:308
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server