Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 4 months 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 (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-07T03:33:41.000Z (9 months ago)
- Last Synced: 2024-09-29T20:04:41.044Z (4 months ago)
- Topics: isolated, patch, php, phpunit, testing
- Language: PHP
- Homepage:
- Size: 20.5 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 [![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)
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`## 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'
```