test: remove 22 redundant test cases#98
Conversation
Remove tests that pin no distinct failure mode, in four groups: - value-type variations (string/array/object/int payloads through unwrap/unwrapErr/unwrapOr): the accessors are single-statement returns with no branching, so payload type cannot change the code path; the base test per method remains - falsy-value pins: keep null (isset-style bugs) and false (truthiness bugs) per class; 0 and '' repeat the false failure mode - runtime 'type change' tests (map/mapErr/match/andThen with different value or error types): PHP is dynamically typed, so these re-run the same path as the base tests; the type-composition claims they alluded to are pinned at the right layer by assertType tests in tests/Types/result.php - evolution leftovers subsumed by stronger tests: expect_throws_withGivenMessage and expectErr_throws_withGivenMessage are strictly implied by the *_throwsUnwrapException variants, and unwrapException_remainsCatchableAsLogicException is the conjunction of unwrap_throws_exception (LogicException) and unwrap_throwsUnwrapException_withErrorValueInMessage Every removed test has a kept twin exercising the same code path, so line coverage of src/ is unchanged (verified: 77 tests green, PHPStan level max clean). Claude-Session: https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK
Walkthroughtests/ErrTest.php から、Err の例外処理・型変換・境界値・エラー保持等に関する複数のテストメソッドが削除され、unwrapOr_returns_default テストが追加された。公開エンティティの変更はなし。 ChangesErrテストの整理
Estimated code review effort: 2 (Simple) | ~10 minutes 関連する懸念事項(レビューコメント):
Suggested labels: tests, needs-discussion Suggested reviewers: valbeat 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request simplifies the test suites in tests/ErrTest.php and tests/OkTest.php by removing numerous redundant test cases, including those verifying specific type behaviors, empty values, and exception handling. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #98 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 65 65
===========================================
Files 4 4
Lines 130 130
===========================================
Hits 130 130
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
This PR reduces maintenance noise in the PHP Result test suite by removing redundant test cases that don’t exercise distinct failure modes, aiming to keep coverage signal while lowering duplicated assertions.
Changes:
- Removes redundant
Oktests that only vary input types or return-type shapes (unwrap,map,andThen,match) without changing code paths. - Removes redundant
Errtests for value-type variations and return-type variations where behavior is already covered by remaining core tests. - Keeps “unique failure mode” tests in place (e.g., exception/message assertions and named-argument support), while trimming strictly subsumed variants.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/OkTest.php | Deletes redundant Ok-path tests (type-variation and return-shape variants) while retaining core behavior and exception/message coverage. |
| tests/ErrTest.php | Deletes redundant Err-path tests (type-variation and return-shape variants) while retaining core unwrap/expect exception/message coverage and named-argument checks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
概要
テストスイートのレビューで特定した、固有の失敗モードを持たない冗長テスト 22 件を削除します(99 → 77 tests、削除のみ 206 行)。実行時間ではなく、仕様変更時に同じ原因で複数テストが一斉に落ちるノイズと保守コストの削減が目的です。
削除の内訳
0/'')expect_throws_withGivenMessage等は*_throwsUnwrapException変種に包含。UnwrapException extends LogicExceptionの事実は残置テスト(unwrap_throws_exceptionが\LogicExceptionを期待してパス)でピン留め継続残しているもの(一見冗長だが意図あり)
unwrap_throws_exceptionのメッセージプレフィックス検証 — 前方一致に依存する利用者への BC ピンmatch_supportsNamedArgumentsの Ok/Err 両方 — PHP はインターフェースとの引数名一致を強制しないため、クラスごとに独立してドリフトし得るdescribe()のエッジテスト群 — 各々が別分岐をピン検証
https://claude.ai/code/session_017XTM7pxbWPVNLV639i5WgK
Summary by CodeRabbit
unwrap、map、andThen、matchなどの検証対象を簡素化し、unwrapOrの確認を追加しました。