Chore: Replace assertEquals with assertSame#1
Conversation
WalkthroughThe pull request modifies test assertions across two files to enforce stricter type and value comparison. In README.md and tests/AsyncTest.php, loose equality assertions ( Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Rationale: All changes follow a homogeneous refactoring pattern (assertEquals → assertSame), affecting only two files with repetitive, identical modifications. No new logic is introduced, and the changes are consistent cosmetic upgrades to assertion strictness. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.md(1 hunks)tests/AsyncTest.php(2 hunks)
🔇 Additional comments (2)
tests/AsyncTest.php (1)
85-88: LGTM! Stricter type checking is appropriate here.The change from
assertEqualstoassertSamecorrectly enforces strict equality (type + value). Since$counteris always an integer, this is the more appropriate assertion method and follows PHPUnit best practices.README.md (1)
52-52: LGTM! Documentation updated to demonstrate best practices.The change from
assertEqualstoassertSamein the documentation example is consistent with the PR's goal and demonstrates the recommended stricter assertion method for users.
|
|
||
| // Counter should be exactly 2, not more | ||
| $this->assertEquals(2, $counter); | ||
| $this->assertSame(2, $counter); |
There was a problem hiding this comment.
Unreachable assertion after expectException.
This assertion will never execute because the Critical exception thrown at line 47 is caught by PHPUnit (via expectException at line 42), ending the test immediately. The counter verification intended here never occurs.
Consider removing this line or restructuring the test to verify the counter value in a way that's actually reachable.
Note: This is a pre-existing issue not introduced by this PR, but worth addressing while modifying this line.
🤖 Prompt for AI Agents
In tests/AsyncTest.php around line 53, the assertion `$this->assertSame(2,
$counter);` is unreachable because PHPUnit's expectException causes the test to
end when the Critical exception is thrown; either remove this unreachable
assertion or restructure the test so the counter is verified: either (a) move
the counter assertion to before the point that triggers the exception, or (b)
remove expectException and wrap the code that throws in a try/catch, asserting
the counter in the catch (and rethrow or assert the exception) so the counter
check runs.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.