Ressources
Introduction
- Why we are writing fewer tests than necessary
- Why do we need tests in the first place?
- So, what should I be testing exactly?
- Structure of the ebook
What should we be testing in a Laravel CRUD application?
Writing tests for guest user functionalities on a Laravel CRUD application
- Make sure that PHPUnit is working properly with your application
- A guest could see all the articles when visiting
/articles - A guest could see a single article
- A guest could see a user profile
- A guest could not write a new article and gets redirected to the signup page instead
- A guest could visit and get the signup page and + A guest could visit and get the login page
- How would tests detect breaking changes in the code base?
- Conclusion
Testing what signed up users could do on the application
- A user could write an article
- The user could visit and get the “new article” form
- The user should be able to save the newly created article.
- A user could edit her own articles
- The user could visit and get the “edit article” form
- The user should be able to save the updated article
- A user could delete her own articles and get redirected to the all articles page with a success message
- Conclusion
Testing what a logged in user is not allowed to do
- A user should not be able to edit articles she doesn’t own
- A user should not be able to delete articles she doesn’t own
- A user should not be able to create or update articles that bypass the validation rules (short titles and/or short bodies)
- Conclusion
Refactor the tests and create a base test class
- Create a base test class
- Conclusion
Dealing with test data
- Using a dedicated database
- Exclude the test database from your version control
- Conclusion
Set up a Continuous integration tool
- Set up Bitbucket pipelines
- Conclusion