Skip to content

Instantly share code, notes, and snippets.

@christophrumpel
Created January 20, 2020 09:32
Show Gist options
  • Save christophrumpel/772dbe4b639e964e66e6b95c90d7ae60 to your computer and use it in GitHub Desktop.
Save christophrumpel/772dbe4b639e964e66e6b95c90d7ae60 to your computer and use it in GitHub Desktop.
Laravel Factories Reloaded

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 wile 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment