Jad Joubran
Jad Joubran

Reputation: 2579

How can I write an integration test for an endpoint that uses the Storage filesystem in Laravel 5?

I have the following API endpoint (code has been simplified for the purpose of the question):

class TestController{
     public function test(Request $request)
     {
          $this->validate($request, ['picture' => 'required|image']);

          Storage::disk('s3')->put('tests/test.png', file_get_contents($request->file('picture'));

          return 'tests/test.png';
     }

How can I write an integration test for this code in phpunit?
I have a test that works, but the problem is that everytime I run phpunit, it uploads the file to Amazon S3.

Upvotes: 0

Views: 131

Answers (1)

Elie Faës
Elie Faës

Reputation: 3315

You can mock facades in Laravel, see the doc here

Upvotes: 1

Related Questions