Function Mocker stop wrapping things 01

Working to add a functional way to configure Function Mocker.

A duct tape solution

In a rush to fix it I came up with a quick and dirty solution to make function-mocker and Codeception play together.
That’s a duct-tape solution to the problem of which files and at which time Function Mocker is wrapping.

Init and setUp

The FunctionMocker::setUp method is meant to be used in a PHPUnit test case setUp method and not in the bootstrap file; my idea is to store any operation or data contextual to a single test case in that method and nothing else.
I’ve added a method to the class, FunctionMocker::init that’s meant to be used in the test suite bootstrap file (be it a Codeception or a PHPUnit test suite); the below example refers to a Codeception _bootstrap.php file

// This is global bootstrap for autoloading
    use tad\FunctionMocker\FunctionMocker;

    require_once dirname( __FILE__ ) . '/../vendor/autoload.php';


and in the test case nothing changes

use tad\FunctionMocker\FunctionMocker;

class SomeClassTest extends \PHPUnit_Framework_TestCase
    protected function setUp() {

    protected function tearDown() {

     * @test
     * it should... 

What should not be wrapped

The actual solution will exclude some common paths from the patchwork pre-processing like:

  • /vendor/codecept - Codeception folder
  • /vendor/phpunit - PHPUnit folder
  • /vendor/sebastian - PHPunit creator Sebastian Bergmann packages folder
  • vendor/phpspec - phpspec folder
  • vendor/bin - the CLI files folder

I’m working to implement a solution that will allow me to set up this blacklist in a flexible and optionable manner.


I have had some issues with code coverage and am willing to investigate the matter while trying to understand patchwork inner workings.