~/talk

Testing With Fakes

Talkat Laracon US 2023 · 2023-07-19..07-20· [testing, php]
slides:none on file

Shows how Laravel’s built-in fakes turn real side effects into testable assertions: default mailer is an in-memory array and queue driver defaults to sync (causing jobs to run during tests); use Mail::fake and assertOutgoingCount / assertQueued to verify one mailable; use Bus::fake or Bus::fakeExcept / onlyFake to let a downstream job actually run; factories can use createQuietly to suppress model events; HTTP::preventStrayRequests highlights unexpected external calls; real-time facades (prefix with Facades\) let LanguageAI be mocked with expects rather than shouldReceive.

AI-written summary · about

  1. 0:00Introduction to test doubles
  2. 1:45Modern fakes in Laravel
  3. 3:53Testing naive controller actions
  4. 6:16Mail facade fakes explained
  5. 10:32Bus facade fakes and assertions
  6. 14:25Event facade fakes in jobs
  7. 17:52Refactoring with lifecycle events
  8. 20:19HTTP facade fakes for external calls
  9. 25:33Real-time facades and mocking
  10. 29:02Confidence in testing with facades
  11. 29:44Q&A on testing approaches
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.