PHPackages                             bizkit/phpunit-function-mock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. bizkit/phpunit-function-mock

ActiveLibrary[Testing &amp; Quality](/categories/testing)

bizkit/phpunit-function-mock
============================

Provides a small PHPUnit extension for mocking native PHP functions from tests.

v1.0.0(1mo ago)02MITPHPPHP &gt;=8.1CI passing

Since Jun 30Pushed 2w ago1 watchersCompare

[ Source](https://github.com/HypeMC/phpunit-function-mock)[ Packagist](https://packagist.org/packages/bizkit/phpunit-function-mock)[ Docs](https://github.com/HypeMC/phpunit-function-mock)[ RSS](/packages/bizkit-phpunit-function-mock/feed)WikiDiscussions 1.x Synced 2w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Bizkit PHPUnit Function Mock
============================

[](#bizkit-phpunit-function-mock)

[![Latest Stable Version](https://camo.githubusercontent.com/fb1318a791e54fe39e0f0d7079057e19da9f3b62015482eea9edeaea2dbf511f/68747470733a2f2f706f7365722e707567782e6f72672f62697a6b69742f706870756e69742d66756e6374696f6e2d6d6f636b2f762f737461626c65)](https://packagist.org/packages/bizkit/phpunit-function-mock)[![Build Status](https://github.com/HypeMC/phpunit-function-mock/actions/workflows/tests.yaml/badge.svg?branch=1.x)](https://github.com/HypeMC/phpunit-function-mock/actions/workflows/tests.yaml)[![Code Coverage](https://camo.githubusercontent.com/eb103b1601cc6dda98cc2eb451e5b4445c1cbda593bd3745d92f2c74455bb3a8/68747470733a2f2f636f6465636f762e696f2f67682f487970654d432f706870756e69742d66756e6374696f6e2d6d6f636b2f6272616e63682f312e782f67726170682f62616467652e737667)](https://codecov.io/gh/HypeMC/phpunit-function-mock)[![License](https://camo.githubusercontent.com/e9cbdb13d1506ed13e463f33b8d7dfdeb0771cddbf21a4525c30b42bd0ff2d69/68747470733a2f2f706f7365722e707567782e6f72672f62697a6b69742f706870756e69742d66756e6374696f6e2d6d6f636b2f6c6963656e7365)](https://packagist.org/packages/bizkit/phpunit-function-mock)

Provides a small PHPUnit extension for mocking native PHP functions from tests.

The idea is based on Symfony PHPUnit Bridge's `ClockMock` and `DnsMock`: register a function in the tested namespace and dispatch that function through a test-controlled mock. See Symfony's [Clock Mocking](https://symfony.com/doc/current/components/phpunit_bridge.html#clock-mocking)and [DNS-sensitive tests](https://symfony.com/doc/current/components/phpunit_bridge.html#dns-sensitive-tests)documentation for the original pattern.

Requirements
------------

[](#requirements)

- [PHP 8.1](https://www.php.net/releases/8_1_0.php) or higher
- PHPUnit 10.5, 11.5, 12.5, 13, or higher

Installation
------------

[](#installation)

```
composer require --dev bizkit/phpunit-function-mock
```

PHPUnit Configuration
---------------------

[](#phpunit-configuration)

Register the extension in your PHPUnit configuration:

```

```

Usage
-----

[](#usage)

Use `#[RegisterFunctionMock]` on the test class or method to register the function hook. Configure the callable in the test body with `FunctionMock`.

```
