Function Mocker 0.4.0 out!

Out, updated and working: function mocker is becoming a tool I can rely on.

The simple code pitch

I will copy and paste the example code that’s at the top of function-mocker README file: I’ve updated it to use the new instance method replacement API and made some refactoring in the meanwhile

use tad\FunctionMocker\FunctionMocker as Test;

class SomeClassTest extends \PHPUnit_Framework_TestCase {

    public function setUp(){

    public function tearDown(){

    public function testSomeMethodCallsSomeFunction(){
        // Setup
        // please note: it can replace not defined functions too!
        $someFunction = Test::replace('some_function');

        // Exercise

        // Assert

        // check primitive call args

        // check primitive type

    public function testSomeMethodCallsSomeStaticMethod(){
        // Setup
        $get_post_title = Test::replace('Post::get_post_title', 'Post title');

        // Exercise
        $this->assertEquals('Post title', Post::get_post_title());

        // Assert

    public function testSomeMethodCallsSomeInstanceMethod(){
        // Setup
        $replacement = Test::replace('Dependency::methodOne');

        // Exercise
        $caller = function(Dependency $dependency){
            $dependency->methodOne('foo', 23);


        // Assert
        $replacement->wasCalledWithOnce([Test::isType('string'), Test::isType('int')]'methodOne');

I will stick with the current feature set for a while and leverage function-mocker replacement power to stick to TDD in WordPress as much as possible.

I appreciate your input