seeResponseCodeIs no longer produce ComparisonFailure object when failed
還沒有人認領這個 Issue。
評估
研究方向
從 seeResponseCodeIs 入口點開始,將其 PHPUnit 斷言行為與所參照的 IsIdentical 和 IsEqual 實作進行比較。重現失敗的 200 對 401 斷言,然後驗證產生的 ExpectationFailedException 再次公開了一個實際值為 401 的 ComparisonFailure。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- PHP
- 星號
- 87
- 分支
- 20
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Codeception/lib-innerbrowser 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 48/100
-
難度 2/5 1-3 小時 新手友好度 35/100
Codeception/lib-innerbrowser#31 · 2 則留言 ·
-
enhancement
難度 3/5 1-2 天 新手友好度 35/100
Codeception/lib-innerbrowser#16 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 35/100
-
難度 2/5 1-3 小時 新手友好度 48/100
Codeception/lib-innerbrowser#61 · 4 則留言 ·
查看 Codeception/lib-innerbrowser 的全部 Issue
相似的 Issue
-
sync-en
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
sync-en
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
Refund Analytics Tool — “Check” Button Fails to Render in WooCommerce 11.2.1可能已有人在做 @MinhazI 今天認領。 未關閉Bug Reports/Analytics type: community contribution
難度 2/5 1-3 小時 新手友好度 70/100
woocommerce/woocommerce#69689 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 60/100
維護者通常 2 天內回覆