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 today

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 21% 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

1338d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/365493?v=4)[daaquan](/maintainers/daaquan)[@daaquan](https://github.com/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.

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

The PHP Unit Testing framework.

20.0k955.1M154.8k](/packages/phpunit-phpunit)[shipmonk/coverage-guard

Enforce code coverage in your CI. Not by percentage, but target core methods. No more untested Facades, Controllers, or Repositories. Allows you to start enforcing coverage for new code only!

5546.7k10](/packages/shipmonk-coverage-guard)

PHPackages © 2026

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