Nishan12's avatar

Testing image Upload

This piece of code works

	Storage::fake('services');

    $file = File::image('test.jpg');

    $response = $this->json('POST', '/services', [
        'image' => $file
    ]);

    Storage::disk('public')->assertExists('/services/'.$file->hashName());
    Storage::disk('public')->delete('/services/'.$file->hashName());

but this does not works

	 Storage::fake('services');

    $file = File::image('test.jpg');

    $response = $this->json('POST', '/services', [
        'image' => $file,
    ]);

    Storage::disk('services')->assertExists($file->hashName());
    Storage::disk('services')->delete($file->hashName());

although the last one is prefered way in the documentation. The folders are created inside the framework/testing/disk but the files are inserted in the public.

Controller Code to store image

$request->file('image')->store('services','public')

0 likes
2 replies

Please or to participate in this conversation.