Codeception / Codeception/lib-innerbrowser

seeResponseCodeIs no longer produce ComparisonFailure object when failed

Đang mở
#65 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
87
Fork
20
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.