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:

  • 59 courses (1056 lessons, 44 h 09 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord