Function mocking with Patchwork 04

The work on the function mocking tool goes on as I close on the last feature.


In my previous post I’ve jotted down the opinions the tool is going to implement about stubs, spies and mocks and am sticking to that guideline to move on.
While the complexity thickens, although not that much thanks to PHPUnit and this inspiring article, keeping the tool API uniform and a slim as possible requires some additional refactoring work.
In the meanwhile the methods mock objects will expose, beside the one that’s being mocked, are going conditional the phpspec way and should come along pretty much like these:


// this function might or might not call `someFunction`

The mock will fail the PHPUnit way if, in this case, the mocked function is called.
For instance methods that’s pretty much the same melody

$mock = FunctionMocker::mock('Class::someMethod')->shouldNotBeCalled();

// this function might or might not call `Class::someMethod`

More to come soon.