// method of test
/** @test */
public function it_can_create_entity()
{
$data = [
'reason' => 'some reason',
'image' => [
UploadedFile::fake()->image('report.jpg', 200, 100)->size(1000),
],
];
$response = $this->json('POST', "route", $data, [
'headers' => [
'Content-Type' => 'multipart/form-data'
]
]);
info($response->getContent());
$response->assertCreated();
}
// method of controller
public function store(Request $request)
{
$request->validate([
'reason' => ['required', 'string'],
'image' => ['nullable', 'file', 'mimes:png,jpg,webp,bmp'],
]);
// остальной код ...
}