lundi 20 mai 2019

Storage fake with factory laravel

I'm trying to use storage fake in the delete, but I dont know how to simulate upload file with factory. My test:

 $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);

If I comment this-> json is still working for more than not delete the photo

and my factory is:

$factory->define(Category::class, function (Faker $faker) {

return [
    'name' => "Category {$faker->firstName}",
    'image_code' => $faker->image('/tmp', 300, 300)
];

});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire