Codeception / Codeception/lib-innerbrowser

seeResponseCodeIs no longer produce ComparisonFailure object when failed

オープン
#65 コメント 0 件 リアクション 0 件 担当者 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

エントリーポイント seeResponseCodeIs から開始し、その PHPUnit のアサーション動作を、参照されている IsIdentical および IsEqual の実装と比較します。200 対 401 の失敗したアサーションを再現し、その結果生じる ExpectationFailedException が、実際の値が 401 である ComparisonFailure を再び公開することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
testing
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。