Courses

Re-creating Booking.com API with Laravel and PHPUnit

While reviewing our tests, I decided we can improve things a bit, by using factories more to have more reusable and shorter code in tests. Let's do exactly that, in this short lesson.

Example:

// Current
$owner = User::factory()->create(['role_id' => Role::ROLE_OWNER]);
 
// Replacing with Factory States
$owner = User::factory()->owner()->create();

This lesson is only for Premium Members.
Want to access all lessons of this course?

You also get:

  • 68 courses (1183 lessons, 43 h 18 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord