https://github.com/mpyw/phpunit-patch-serializable-comparison
Fixes assertSame()/assertEquals() serialization errors running in separate processes.
https://github.com/mpyw/phpunit-patch-serializable-comparison
isolated patch php phpunit testing
Last synced: 20 days ago
JSON representation
Fixes assertSame()/assertEquals() serialization errors running in separate processes.
- Host: GitHub
- URL: https://github.com/mpyw/phpunit-patch-serializable-comparison
- Owner: mpyw
- License: other
- Created: 2021-06-23T11:10:10.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-04T01:17:11.000Z (about 2 months ago)
- Last Synced: 2025-04-01T23:37:08.238Z (28 days ago)
- Topics: isolated, patch, php, phpunit, testing
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 14
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPUnit Patch Serializable Comparison [](https://github.com/mpyw/phpunit-patch-serializable-comparison/actions)
Fixes `assertSame()`/`assertEquals()` serialization errors running in separate processes.
## Requirements
- php: `>=5.3.3`
- [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit): `>=4.8.0`
- [sebastianbergmann/comparator](https://github.com/sebastianbergmann/comparator): `^1.0 || ^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0`## Installing
```bash
composer require --dev mpyw/phpunit-patch-serializable-comparison
```## Example
```php
class AssertionTest extends TestCase
{
protected function callAssertSameReceivingClosure(\Closure $closure)
{
static::assertSame('aaa', 'bbb');
}#[RunInSeparateProcess]
#[PreserveGlobalState(enabled: false)]
public function testAssertionIncludingUnserializableTrace()
{
static::callAssertSameInClosure(function () {});
}
}
```### 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
```diff
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'aaa'
+'bbb'
```