Laravel API 101:
Laravel comes out-of-the-box with great testing suite built on PHPUnit. No API should be left untested.
The hardest part about starting a new lesson is writing an introduction.
In the first part of this serial called BUILD, we have built an API for managing news articles. In this lesson, we will write tests for that API using the PHPUnit testing framework that comes with Laravel by default.
First, we need to set up our testing environment, then we will write the tests following the documentation on Testing JSON APIs.
We need to test five routes:
index- get all articles
store- create an article with authentication
show- get a single article
update- update an article with authentication
delete- delete an article with authentication
- Cover image Bond created by Kristian Gonzales
To continue reading, choose a subscription plan: