create(); $uploadedImage = UploadedFile::fake()->image('0254.png', 100, 100); $imagePath = 'common_catalog/items/1/image/0254.png'; Storage::disk('public')->put($imagePath, $uploadedImage->getContent()); $image = File::query()->create([ 'user_id' => $user->id, 'original_name' => '0254.png', 'mime_type' => 'image/png', 'path' => $imagePath, 'link' => '/storage/'.$imagePath, ]); CommonCatalogItem::factory()->create([ 'article' => '0254', 'calculator_name' => 'Оборудование для благоустройства', 'image_file_id' => $image->id, ]); (new ExportCommonCatalogService)->handle($user->id); $file = File::query()->where('user_id', $user->id)->latest('id')->firstOrFail(); Storage::disk('public')->assertExists($file->path); $sheet = IOFactory::load(Storage::disk('public')->path($file->path))->getActiveSheet(); $this->assertSame(ExportCommonCatalogService::HEADERS, $sheet->rangeToArray('A1:S1')[0]); $this->assertSame('0254', $sheet->getCell('C2')->getValue()); $this->assertSame('Оборудование для благоустройства', $sheet->getCell('D2')->getValue()); $this->assertCount(1, $sheet->getDrawingCollection()); } }