Testing your route in PHPUnit

As seen in the preceding recipe, I used the browser to show that the API is working. Here, I want to show how you can speed up your workflow by using PHPUnit to do this and then, more importantly, you end up with long term testing.

Getting ready

The previous recipes will help show how to lay the foundation. In this one, I will continue from there.

How to do it…

Follow these steps to test your route:

  1. Make a test:
    > php artisan make:test SearchComicsApiTest
  2. Then, edit the file tests/SearchComicsApiTest.php:
    How to do it…
  3. And run phpunit:
    > phpunit --filter=api_results_from_search_verify_format
  4. Now let's make it do something by hitting that ...

Get Laravel 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.