Courses

Testing in Laravel 12 For Beginners

Should We Test Code From Packages?

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Evaluating when to test external package functionality
- Understanding package authors' test coverage
- Testing application behavior rather than package internals
- Following Laravel's emphasis on Feature tests

Another sub-question to cover on the topic of "what to test": should we test something that is covered by external Laravel/PHP packages?

For example, you use a Spatie package laravel-tags to have tags in your Eloquent models. Should you write a test that the tag is inserted successfully if you do that by calling the function from that package?

That is a debatable question, but most serious package creators include tests in their packages, so package users would not need to test that or retest it manually externally.

So, for example, if we go to test folder of that package, there are quite a lot of tests asserting that if you add a tag, for example, it can create a tag, assert count, assert same, etc. So...

The full lesson is only for Premium Members.
Want to access all 25 lessons of this course? (90 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord