PHPackages                             phpfan/phpunit-patch - 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. phpfan/phpunit-patch

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

phpfan/phpunit-patch
====================

Fixes assertSame/assertEquals serialization errors running in separate processes.

v1.1(3y ago)021MITPHPPHP &gt;=7.4

Since Aug 25Pushed 3y agoCompare

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

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

PHPUnit Patch Serializable Comparison [![Status](https://github.com/mpyw/phpunit-patch-serializable-comparison/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/mpyw/phpunit-patch-serializable-comparison/actions)
==========================================================================================================================================================================================================================================

[](#phpunit-patch-serializable-comparison-)

Fixes `assertSame()`/`assertEquals()` serialization errors running in separate processes.

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

[](#requirements)

- php: `>=7.4`
- [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit): `=9.5`
- [sebastianbergmann/comparator](https://github.com/sebastianbergmann/comparator): `^4.0`

Installing
----------

[](#installing)

```
composer require --dev phpfan/phpunit-patch
```

Example
-------

[](#example)

```
class AssertionTest extends TestCase
{
    protected function callAssertSameReceivingClosure(\Closure $closure)
    {
        static::assertSame('aaa', 'bbb');
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function testAssertionIncludingUnserializableTrace()
    {
        static::callAssertSameInClosure(function () {});
    }
}
```

### Before Patching

[](#before-patching)

```
PHPUnit\Framework\Exception: PHP Fatal error:  Uncaught Exception: Serialization of 'Closure' is not allowed in Standard input code:XX
Stack trace:
#0 Standard input code(XX): serialize(Array)
#1 Standard input code(XX): __phpunit_run_isolated_test()
#2 {main}
  thrown in Standard input code on line XX

```

### After Patching

[](#after-patching)

```
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'aaa'
+'bbb'
```

```
class DataProviderTest extends TestCase
{
    public function provideAdditionTestParams()
    {
        return [
            'say hello' => [
                function ($mr) {
                    return "Hello, $mr!";
                }
            ],
            'hello arrow' => [fn($ms) => "Hello, $ms!"]
        ];
    }

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     * @dataProvider provideAdditionTestParams
     */
    public function testUseClosureDataProviderTest($data)
    {
        self::assertSame('Hello, aaa!', $data('aaa'));
    }
}
```

### Before Patching

[](#before-patching-1)

```
Serialization of 'Closure' is not allowed

```

### After Patching

[](#after-patching-1)

```
Time: 00:00.213, Memory: 6.00 MB

OK (2 tests, 2 assertions)

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% 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 ~69 days

Total

2

Last Release

1293d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c79e3c06f6b0d88502ade704df9d5307f83e706a10dd3a80781d711ece27f1e5?d=identicon)[daaquan](/maintainers/daaquan)

---

Top Contributors

[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (13 commits)")[![daaquan](https://avatars.githubusercontent.com/u/365493?v=4)](https://github.com/daaquan "daaquan (4 commits)")

---

Tags

phpunitprocessisolationserializationpatchprocessesseparatebugfix

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpfan-phpunit-patch/health.svg)

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

###  Alternatives

[mpyw/phpunit-patch-serializable-comparison

Fixes assertSame/assertEquals serialization errors running in separate processes.

15245.5k](/packages/mpyw-phpunit-patch-serializable-comparison)[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-invoker

Invoke callables with a timeout

1.3k540.0M285](/packages/phpunit-php-invoker)[dama/doctrine-test-bundle

Symfony bundle to isolate doctrine database tests and improve test performance

1.2k37.2M144](/packages/dama-doctrine-test-bundle)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69617.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

57026.3M456](/packages/dg-bypass-finals)

PHPackages © 2026

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