A more functional solution to Function Mocker indiscriminate input wrapping.
Update code
I’ve update function-mocker and pushed its latest version to ship with the FunctionMocker::init
method.
This will allow for more selective and less intrusive wrapping to happen while still allowing a lazy approach using the FunctionMocker::setUp
method.
An abstract from the updated README:
By default any library in the
vendor
folder will be excluded from the input wrapping and everything else will be included. If files in any of thevendor
sub-folders need to be wrapped for testing purposes, or a folder that’s not in thevendor
folder needs to be excluded, then an array of options can be passed to theinit
method like
<?php
// This is global bootstrap for autoloading
use tad\FunctionMocker\FunctionMocker;
require_once dirname( __FILE__ ) . '/../vendor/autoload.php';
FunctionMocker::init([
'include' => ['vendor/package', 'vendor/another'],
'exclude' => ['libs/folder', 'src/another-folder']
]);
If the call to the
init
method is omitted then it will be called on the first call to thesetUp
method in the tests.
Next
Time to put the library under some more work and wait for the next bug/issue to happen.