Better than yesterday.

Function mocking with Patchwork

Ad hoc adapters are not necessary if function mocking is all that’s needed.

The problem

I’m trying to come up with an easy to use and adopt solution to write WordPress plugins and themes using TDD techniques and the pervasive use of globally defined functions in WordPress makes it difficult.
While playing around with patchwork I’ve tested if Patchwork could make it: it does very easily as seen in this PHPUnit tests

The function mocker

While function mocking is not the way I will be walking as I will not mock interfaces I do not own (see Growing Object-Oriented Software Guided by Tests) I can see myself using it while working on pre-existing code and it seems so easy that I just can not pass.
That’s why I’ve pushed the project on GitHub.
Now that’s done being able to mock WordPress functions like this