Part 26 - Handle errors for Create User endpoint [How to use TDD to build a REST API in Laravel 6]

Опубликовано: 22 Март 2026
на канале: StudyStream+
146
2

Now I mentioned this before, don’t feel like you are restricted by TDD. We created a test to create a user and added the code to make the test pass. However we added extra logic which is not covered by our tests. The extra logic is the handling error bit.

It seems counter intuitive, to remove this logic just because we don’t have a test for it, then write the test and add the logic back.

Wherever possible, I try to make my commits small and covered by tests. So ideally, I would not commit in this scenario until I have covered the error handling.

So let’s write a test for the error handling. We should just be able to copy from one the Post test.

We can take the data provider as well. Make sure to update the method to handle a User rather than a Post. Run the test. Everything should pass.

Watch the next video here:
   • Part 27 - Install tymon/jwt-auth into Lara...  

Laravel Tutorials:
   • Laravel PHP Tutorials  

2 - 3 min Developer Quick Tips Series:
https://www.youtube.com/playlist?list... this course in full here:
   • How to use TDD to build a REST API in Lara...