PHPackages                             bonemeijer/phpunit-extensions - 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. bonemeijer/phpunit-extensions

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

bonemeijer/phpunit-extensions
=============================

A simple library of helper components for PHPUnit tests

v0.1.2(6mo ago)021MITPHPPHP &gt;=8.3.0

Since Oct 17Pushed 6mo agoCompare

[ Source](https://github.com/Bonemeijer/phpunit-extensions)[ Packagist](https://packagist.org/packages/bonemeijer/phpunit-extensions)[ Docs](https://github.com/Bonemeijer/phpunit-extensions)[ RSS](/packages/bonemeijer-phpunit-extensions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (1)

Bonemeijer/phpunit-extensions
=============================

[](#bonemeijerphpunit-extensions)

A simple library of helper components for PhpUnit tests.

The goal is to provide some simple time-saving PhpUnit extensions.

[![Latest Stable Version](https://camo.githubusercontent.com/f788971e095d26ce962ea5b4ad33b6a9250c1115f22719fe934b095d72136bb8/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f706870756e69742d657874656e73696f6e732f762f737461626c65)](https://packagist.org/packages/bonemeijer/phpunit-extensions)[![Total Downloads](https://camo.githubusercontent.com/f1755eedf028132213898f2cab8b05704a94c94c042ce7f647cc5a16196bce9a/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f706870756e69742d657874656e73696f6e732f646f776e6c6f616473)](https://packagist.org/packages/bonemeijer/phpunit-extensions)[![License](https://camo.githubusercontent.com/405f266acf31abe1b457946f870b60e2c76cd9bd0aedf5e0b5f241192609b379/68747470733a2f2f706f7365722e707567782e6f72672f626f6e656d65696a65722f706870756e69742d657874656e73696f6e732f6c6963656e7365)](https://packagist.org/packages/bonemeijer/phpunit-extensions)

### Installing

[](#installing)

This project is still in beta. Backwards incompatible changes **will** be introduced during this time.

```
composer require bonemeijer/phpunit-extensions --dev

```

JSON Assertion
--------------

[](#json-assertion)

This package provides a quick way to assert arbitrary data by dumping it to a JSON file and comparing it afterward.

Example:

```
class JsonAssertionTraitTest extends TestCase
{
    // This trait provides the functionality
    use JsonAssertionTrait;

    public function testSomething(): void
    {
        $someUnit = new SomeUnit();

        try {
            $output = $someUnit->doSomething();
        } catch (\Throwable $exception) {
            // Capture exception to use in assertion data
        }

        // This will build the assertion file. Nothing is dumped or asserted yet.
        // The received data should be the current state
        $assertion = $this->getJsonAssertion(
            [
                'output'    => $output,
                'exception' => isset($exception)
                    ? [
                        'class'   => get_class($exception),
                        'message' => $exception->getMessage(),
                    ]
                    : null,
            ],
        );

        // This will run the assertion logic
        $assertion->assertSame();
    }
}
```

When calling `assertSame()`, the following logic will be applied:

- If the assertion file does not exist, it will be created and the current test will be marked as `skipped`.
- If the assertion file exists, the data passed to `getJsonAssertion` will be compared to the dumped file. If it matches, the test will pass. If it does not match, the test will fail.

### Updating assertions

[](#updating-assertions)

To quickly update any assertions, you can set the `UPDATE_ASSERTIONS=1` environment variable. Or use the shortcut `UA=1`.

```
# Update all assertions
UPDATE_ASSERTIONS=1 vendor/bin/phpunit

# Update all assertions using shortcut
UA=1 vendor/bin/phpunit

# Update only a specific test
UA=1 vendor/bin/phpunit --filter SomeUnitTest
```

When you commit the assertion dump to a VCS like GIT, you can then easily verify any changes by rerunning the test suite with `UPDATE_ASSERTIONS=1`. The GIT diff will show you the changes in output.

Deployment
----------

[](#deployment)

Don't deploy test tools. Which is why the Composer `--dev` flag is recommended.

Versioning
----------

[](#versioning)

This package uses [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/Bonemeijer/phpunit-extensions/tags).

Authors
-------

[](#authors)

- **Maurice Bonemeijer** - *Initial work* - [Bonemeijer](https://github.com/Bonemeijer)

See also the list of [contributors](https://github.com/Bonemeijer/phpunit-extensions/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance70

Regular maintenance activity

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

204d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/230fc27832a74a1c8db5dd6f736f0ea7c5d8ec500b374036b60352bc4b273361?d=identicon)[Bonemeijer](/maintainers/Bonemeijer)

---

Top Contributors

[![Bonemeijer](https://avatars.githubusercontent.com/u/7499085?v=4)](https://github.com/Bonemeijer "Bonemeijer (8 commits)")

---

Tags

phpunit

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bonemeijer-phpunit-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/bonemeijer-phpunit-extensions/health.svg)](https://phpackages.com/packages/bonemeijer-phpunit-extensions)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.0k](/packages/phpunit-phpunit)[brianium/paratest

Parallel testing for PHP

2.5k118.8M753](/packages/brianium-paratest)[johnkary/phpunit-speedtrap

Find and report on slow tests in your PHPUnit test suite

78137.2M121](/packages/johnkary-phpunit-speedtrap)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69417.9M510](/packages/spatie-phpunit-snapshot-assertions)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

56426.3M455](/packages/dg-bypass-finals)[phpspec/prophecy-phpunit

Integrating the Prophecy mocking library in PHPUnit test cases

19254.9M1.4k](/packages/phpspec-prophecy-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
