Laravel Factories Reloaded (Laracon Online)

Laravel Factories Reloaded (Laracon Online)

While testing our Laravel applications, we often need to work with dummy data. Most of the time, it is model instances that we require, and Laravel has an excellent factory system to helps us creating them.

It works great, but the bigger your applications get, the more difficult it gets to prepare your test data. For example, instead of a user, you might need a user who is admin, has created three articles within the category support and is active. What happens now is that your tests get bloated while you create all these models and relationships. This is when it gets messy, and your tests are not good to follow anymore.

In this talk, I want to show you how we can handle these situations and what my best-practices are regarding Laravel factories. Attendees will be able to use these practices to keep their factories and tests clean and enjoyable.

14d39e65f615fd6dcb9dd44ea7f7995b?s=128

Christoph Rumpel

February 26, 2020
Tweet

Transcript

  1. 4.

    Laravel Factories Reloaded Package Test Factories (Brent from Spatie) Tidying

    Up Your PHPUnit Tests with Class- Based Model Factories (Tighten) MORE ON THIS TOPIC