dms/phpunit-arraysubset-asserts
Composer 安装命令:
composer require dms/phpunit-arraysubset-asserts
包简介
This package provides ArraySubset and related asserts once deprecated in PHPUnit 8
README 文档
README
In PHPUnit 8 the function assertArraySubset was deprecated. This function was often misunderstood and thus removed, but it still holds true as a very useful tool, hence it was extracted here.
Disclaimer: The initial version contained here is copied over from phpunit and is heavily based on the original work by Márcio Almada.
Installation
Simply use it by importing it with Composer
composer require --dev dms/phpunit-arraysubset-asserts
💡 The package can be safely required on PHP 5.4 to current in combination with PHPUnit 4.8.36/5.7.21 to current.
When the PHPUnit
assertArraySubset()method is natively available and not deprecated (PHPUnit 4.x - 7.x), the PHPUnit native functionality will be used. For PHPUnit 8 and higher, the extension will kick in and polyfill the functionality which was removed from PHPUnit.
Usage
You have two options to use this in your classes: either directly as a static call or as a trait if you wish to keep existing references working.
Trait use example
<?php namespace Your\Package\Tests; use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use PHPUnit\Framework\TestCase; final class ExampleTest extends TestCase { use ArraySubsetAsserts; public function testWithTrait(): void { $expectedSubset = ['bar' => 0]; $content = ['bar' => '0']; self::assertArraySubset($expectedSubset, $content, true); $content = ['foo' => '1']; $this->assertArraySubset($expectedSubset, $content, true); } }
Static class method example
<?php namespace Your\Package\Tests; use DMS\PHPUnitExtensions\ArraySubset\Assert; use PHPUnit\Framework\TestCase; final class ExampleTest extends TestCase { public function testWithDirectCall(): void { $expectedSubset = ['bar' => 0]; $content = ['bar' => '0']; Assert::assertArraySubset($expectedSubset, $content, true); } }
dms/phpunit-arraysubset-asserts 适用场景与选型建议
dms/phpunit-arraysubset-asserts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.07M 次下载、GitHub Stars 达 142, 最近一次更新时间为 2019 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 dms/phpunit-arraysubset-asserts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dms/phpunit-arraysubset-asserts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 29.07M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 144
- 点击次数: 20
- 依赖项目数: 301
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-17