Codeception / Codeception/lib-innerbrowser

seeResponseCodeIs no longer produce ComparisonFailure object when failed

未关闭
#65 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
PHP
星标
87
派生
20
PR 合并指标
30 天内没有已合并 PR

描述

Hello,

Since 2.x, method seeResponseCodeIs is no longer generating a object ComparisonFailure within the exception when the assertion failed.

This change come from the usage of assertSame instead of assertEquals.

Based on PHPUnit, assertSame generate a ComparisonFailure object only if both values are a string or an array (https://github.com/sebastianbergmann/phpunit/blob/0c37cbcbfdc72425c984460660ac4514918b112e/src/Framework/Constraint/IsIdentical.php#L55 while assertEquals always generate it (https://github.com/sebastianbergmann/phpunit/blob/0c37cbcbfdc72425c984460660ac4514918b112e/src/Framework/Constraint/Equality/IsEqual.php)

Because of this change, the following code no longer works :
```
try {
$this->seeResponseCodeIs(200);
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
if ($e->getComparisonFailure()->getActual() === 401) {
// Doing something else
}
}
```

Is there a reason to use assertSame instead of assertEquals in this case ? Do you think it could be changed ?

Thank you for your time.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。