【发布时间】:2019-10-07 08:24:39
【问题描述】:
我正在尝试在删除中使用存储假,但我不知道如何使用工厂模拟上传文件。我的测试:
$actualCategory = factory(Category::class)->create();
$this->json(
'DELETE',
'/api/category/' . $actualCategory->id
)->assertStatus(200)
->assertJsonStructure([
'success',
'data' => [
'id',
'name',
'image_code',
'updated_at',
'deleted_at',
'created_at'
]
]);
$this->assertSoftDeleted('categories', [
'id' => $actualCategory->id,
'name' => $actualCategory->name
]);
Storage::disk('categories')->assertMissing($actualCategory->image_code);
如果我对此发表评论-> json 仍在工作而不是删除照片
我的工厂是:
$factory->define(Category::class, function (Faker $faker) {
return [
'name' => "Category {$faker->firstName}",
'image_code' => $faker->image('/tmp', 300, 300)
];
});
【问题讨论】: