Batch replacing functions in tests

As announced in a previous post I’ve implemented batch replacement of functions and methods in function-mocker.
The idea behind the implementation is to make the set up of testing environments for heavily function dependent software components (say WordPress…) a less daunting task.

See the README for more information and take a peek at the example below:

 * @test
 * it should allow batch replacement of instance methods
public function it_should_allow_batch_replacement_of_instance_methods() {
    $_functions = [ 'instanceMethodOne', 'instanceMethodTwo', 'instanceMethodThree' ];

    $replacement = FunctionMocker::replace( $functions, 'foo' );

    $this->assertEquals( 'foo', $replacement->instanceMethodOne() );
    $this->assertEquals( 'foo', $replacement->instanceMethodTwo() );
    $this->assertEquals( 'foo', $replacement->instanceMethodThree() );

    $replacement->wasCalledOnce( 'instanceMethodOne' );
    $replacement->wasCalledTimes( 2, 'instanceMethodTwo' );
    $replacement->wasCalledOnce( 'instanceMethodThree' );

I appreciate your input