1. Junior

    What is the Pest PHP testing framework, and why has it become a preferred option for modern Laravel tests over PHPUnit?

    Pest is a clean framework built on PHPUnit that offers concise functional syntax (Expectation API) and intuitive error output while remaining fully compatible with PHPUnit features and tests.

    Read the full explanation
  2. Junior

    How do you write integrated Laravel Feature tests for API endpoints and validate JSON responses?

    Use methods such as $this->getJson() or postJson(), and check results with assertions such as assertStatus(200), assertJsonPath(), and assertJsonValidationErrors().

    Read the full explanation
  3. Mid-level

    How do the RefreshDatabase Trait and DatabaseTransactions differ in Laravel tests?

    RefreshDatabase runs migrations once and isolates each test in a transaction that is rolled back at the end, while DatabaseTransactions wraps only the test in a transaction and requires an already prepared database.

    Read the full explanation
  4. Junior

    How do Model Factories and Faker simplify preparing test data?

    They create fake, consistent model records that match the database through User::factory()->create(), with options to override fields and generate preset States.

    Read the full explanation
  5. Mid-level

    How do you replace services and Facades with Mocks in Laravel tests without breaking the system?

    Use built-in fakes such as Event::fake(), Queue::fake(), or Mail::fake(), and verify sends with Mail::assertSent().

    Read the full explanation
  6. Mid-level

    How do you control and freeze system time in Laravel tests that depend on timeouts?

    Use built-in time travel methods such as $this->travel(5)->days() or $this->freezeTime() to test expiration precisely.

    Read the full explanation
  7. Mid-level

    How do multi-channel Notifications work in Laravel, and how do you test them with Notification::fake()?

    They send a unified notification through multiple channels (mail, database, sms, broadcast) selected by via(), and can be tested with Notification::fake().

    Read the full explanation
  8. Mid-level

    How do you test Jobs, Events, and mail in Laravel with fakes (Queue::fake, Event::fake, and Mail::fake)?

    Fakes replace real execution with a recorder, letting you verify after the code runs that the job, event, or message was dispatched with the right data without actually running it.

    Read the full explanation
  9. Mid-level

    How do you test authentication and authorization (actingAs, Gates, and Policies) in Laravel applications?

    Simulate the current user with actingAs and check response codes (401 for a guest, 403 for an unauthorized user, 200 for the owner); test Policies directly with Gate::forUser or $user->can.

    Read the full explanation
  10. Mid-level

    How do you test code that calls external APIs with Http::fake() and prevent real requests?

    Http::fake intercepts HTTP client calls and returns predefined responses by pattern; Http::preventStrayRequests() blocks any unmocked request from reaching the real network.

    Read the full explanation