Code that calls time() or new DateTime() internally cannot be tested at a chosen moment. The usual workarounds are a sleep() in the test, which makes the suite…
Testing the same behaviour across several inputs usually produces six near-identical methods, and when the assertion needs changing it has to change six times. A data provider separates…
The principle is abstract until you write the test. If exercising one method means stubbing five others that the code under test never calls, the interface is doing…
Coverage records every line executed during a test, not every line the test was checking. A unit test for an invoice calculator that happens to construct three collaborators…
Two hundred and forty require_once calls where load order was load-bearing, moved onto an autoloader one namespace at a time without a big-bang rewrite.
PHPUnit builds a fresh instance of the test class for every test method, so anything assigned in setUp() is rebuilt each time. That isolation is the point, and…
Chasing one failure through a suite that takes four minutes usually ends with the other tests commented out — and one of them staying commented out, which nobody…