~/talk

Mocking Dependencies in Unit Tests with Phake

Talkat PHP UK Conference 2016 · 2016-02-18..02-19· [testing]
links:none on file
slides:none on file

Claims Phake provides a clearer, more featureful mocking API than PHPUnit and removes common hassles around stubbing, verification and ordering. Examples show installing via composer install, creating mocks with Phake::mock(), stubbing returns and callbacks, verifying call order and counts, capturing complex arguments, and using PHPUnit constraints for flexible expectations. Caveats include PHP limits around private, static and final methods and a few rough edges in Phake itself, but verifications produce readable failure messages and the library is usable as demonstrated.

AI-written summary · about

  1. 0:00Intro
  2. 2:25Mike Lively
  3. 6:34Example Class Under Test
  4. 7:26Test Doubles
  5. 12:13Example Test With Stubbing
  6. 13:57Stub Behaviors
  7. 15:08private Methods
  8. 19:56Stubbing static Method Calls
  9. 21:06final Methods
  10. 21:30Stubbing final Method Calls
  11. 22:09Magic Methods
  12. 29:38Verifying Identical Invocations
  13. 30:34Verifying No Interaction
  14. 34:50PHPUnit Constraints
  15. 35:55Wildcard Parameters
  16. 39:03PHPUnit: Mocking
  17. 42:36PHPUnit: Verifying Order
~/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.