Phpunit: 7.2.5 打破 BC !

创建于 2018-06-21  ·  4评论  ·  资料来源: sebastianbergmann/phpunit

| 问 | 一种
| --------------------| ---------------
| PHPUnit 版本 | 7.2.5
| PHP版本| 7.1,例如
| 安装方法 | 作曲家,但无所谓

新发布的 7.2.5 打破了 BC:
https://github.com/sebastianbergmann/phpunit/commit/bcb4c788c7872cd2f885ccf50285f6feb7cfff1a#diff -9ae7a972d07df5f73629d5d315bf405aR521

方法的正式声明已更改:

-    public static function assertNotEquals($expected, $actual, string $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false): void
+    public static function assertNotEquals($expected, $actual, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void

为此,我的集成在不兼容的方法标头上崩溃:
https://travis-ci.org/FriendsOfPHP/PHP-CS-Fixer/jobs/394945074#L655

PHP Fatal error:  Uncaught Declaration of
PHPUnitGoodPractices\Traits\IdentityOverEqualityTrait::assertNotEquals($expected, $actual, string $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false): void
should be compatible with
PHPUnit\Framework\Assert::assertNotEquals($expected, $actual, string $message = '', float $delta = 0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void

最有用的评论

然后我将在 PHPUnit 8 中使它们final :-)

所有4条评论

为什么人们会覆盖 PHPUnit 的断言?

短篇故事? 因为它们没有被标记为最终的

很长的故事? 为我的具体案例提供https://github.com/PHPUnitGoodPractices/Traits/blob/master/src/IdentityOverEqualityTrait.php#L46 -L56

然后我将在 PHPUnit 8 中使它们final :-)

那么,我们可以先从注册断言/期望的死题中提取出来吗? 因此,可以决定在全局范围内提供一些额外的断言(在每个测试中都无需手动导入)或不注册所有内置断言?
但总的来说, :+1: 对于最终方法/类/通过具体实现公开接口

另外,让我再一次请求这个 ;) 请让我们开始使用@internal标签来处理 BC 承诺之外的事情,这将不会在这个库之外使用。
(例如,我可以准备 PR,将所有内容都标记为内部,然后我们将开放应该公开的内容)

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

sebastianbergmann picture sebastianbergmann  ·  23评论

constup picture constup  ·  19评论

weynhamz picture weynhamz  ·  26评论

sebastianbergmann picture sebastianbergmann  ·  33评论

sebastianbergmann picture sebastianbergmann  ·  31评论