Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Allow mocking otherwise unmockable functions with PHPUnit
branch: master

Merge pull request #5 from ktzouno/master

Adding a comment to make more clear how the FunctionMocker works
latest commit 9a06a1be73
@lstrojny authored
Failed to load latest commit information.
build Build infra
tests/PHPUnitTests/Extension Making method static
.gitignore Build infra
.travis.yml Update
build.xml Build infra
composer.json Adding PHP 5.3 as a dep
phpunit.xml.dist Completing blacklisting

PHPUnit function mocker extension

Allows mocking otherwise untestable PHP functions through the use of namespaces.

Gitter Build Status Dependency Status Average time to resolve an issue Percentage of issues still open

namespace MyNamespace;

class Tool
    public function isString($string)
        return strlen($string) > 0 && ctype_alpha($string);

require_once 'PHPUnit/Extension/FunctionMocker.php';

class MyTestCase extends PHPUnit_Framework_TestCase
    public function setUp()
        $this->php = PHPUnit_Extension_FunctionMocker::start($this, 'MyNamespace')

    /** @runInSeparateProcess */
    public function testIsStringUsesStrlenAndCtypeAlpha()

        $tool = new MyNamespace\Tool();


Use @runInSeparateProcess annotation to make sure that the mocking is reliably working in PHP >=5.4

Something went wrong with that request. Please try again.