Testing Amazon S3 file upload using Laravel 5.2 and Mockery2 min read

Having issues testing Amazon S3 file upload controller using Laravel 5.2? Here’s how.

We will be using:

  • Laravel 5.2 Validations
  • Mockery
  • phpunit

Setting up your controller:

Add your file route to app/Http/routes.php  file.

Create your FileRequest file with the required validations in app/Http/Requests/FileRequest.php :

Create your FileController file at app/Http/Controllers/FileController.php

Creating phpunit test

Add your controller test file at tests/FileControllerTest.php

Finally run phpunit  from your Laravel root path.

Screen Shot 2016-04-24 at 12.16.49 AM