承接 phpfan/phpunit-patch 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpfan/phpunit-patch

最新稳定版本:v1.1

Composer 安装命令:

composer require phpfan/phpunit-patch

包简介

Fixes assertSame/assertEquals serialization errors running in separate processes.

README 文档

README

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

Requirements

Installing

composer require --dev phpfan/phpunit-patch

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

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

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

Serialization of 'Closure' is not allowed

After Patching

Time: 00:00.213, Memory: 6.00 MB

OK (2 tests, 2 assertions)

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固