Retiring a double
Understudy::forget($replaced);For the double a test built and then replaced. $this->generator = $this->fixedGenerator('other') leaves the first one behind, still holding its stubs.
Under verifyAll(strictStubs: true) that stub is a failure about a double the test no longer uses. forget() retires it, so verification, accounting and reset stop seeing it.
Afterward
Calling anything on the object — or asking about its calls — fails with ForgottenDouble, which names forget() rather than sending you looking for a reset() you never wrote.
One-way, like every other form of forgetting here.
forget() against reset()
| Scope | |
|---|---|
Understudy::forget($double) | one double, retired from the current context |
Understudy::reset() | every double, registration and transcript the test put in place |
Understudy::reset();
Understudy::idle(); // true when the current context holds no doublesThe Testo and PHPUnit adapters call reset() for you after every test. Without one, call it in your own teardown.
idle() is the check a base class can make to catch a suite where something leaks between tests.