Function Mocker and PHPUnit constraints is live!

Flexible argument check in Function Mocker thanks to PHPUnit constraints.

I’ve just updated the function-mocker package to allow the usage of PHPUnit constraints when checking a function or method call arguments.
While not ground breaking in appearance the release deserved the 0.3.0 release to celebrate the new feature; test code like the one below is not possible

use tad\FunctionMocker\FunctionMocker as Test;

class SomeTest extends PHPUnit_Framework_TestCase {

    public function firstTest(){

        $replacedFunction = Test::replace('someFunction');


        // primitive type argument check
        $replacedFunction->wasCalledWithOnce([23, 'foo']);

        // constraint argument check
        $replacedFunction->wasCalledWithOnce([Test::isType('int'), Test::isType('string')]);


    public function secondTest(){

        $replacedStaticMethod = Test::replace('SomeClass::someMethod');

        SomeClass::someMethod(23, new stdClass());

        $replacedStaticMethod->wasCalledWithOnce(['23', Test::isInstanceOf('stdClass')]);


   public function thirdTest(){

        $mock = Test::replace('SomeClass::instanceMethod');

        $mock->instanceMethod(23, 'foo');

        $mock->wasCalledWithOnce([Test::isType('int'), Test::isType('string')], 'instanceMethod');



The tool is moving forward as something that can make testing almost anything a real possibility.