-
-
Notifications
You must be signed in to change notification settings - Fork 1
test(StatelessApplicationTest): Add test for handling UserException in ErrorHandler class.
#49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… in `ErrorHandler` class.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #49 +/- ##
=========================================
Coverage 98.23% 98.23%
Complexity 289 289
=========================================
Files 12 12
Lines 735 735
=========================================
Hits 722 722
Misses 13 13 ☔ View full report in Codecov by Sentry. |
WalkthroughA new test method was added to the Changes
Sequence Diagram(s)sequenceDiagram
participant TestCase
participant StatelessApplication
participant ErrorHandler
participant UserException
TestCase->>StatelessApplication: Create instance with error handler config
TestCase->>ErrorHandler: Set discardExistingOutput to false
TestCase->>UserException: Create with user-friendly message
TestCase->>ErrorHandler: handleException(UserException)
ErrorHandler->>StatelessApplication: Generate HTML error response
StatelessApplication-->>TestCase: Return response
TestCase->>TestCase: Assert response status, format, and content
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/http/StatelessApplicationTest.php(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: terabytesoftw
PR: yii2-extensions/psr-bridge#6
File: tests/http/RequestTest.php:1536-1552
Timestamp: 2025-07-20T16:35:15.341Z
Learning: In the yii2-extensions/psr-bridge project, the base TestCase class already handles $_SERVER cleanup in setUp() and tearDown() methods (lines 28 and 32), so individual test methods that extend TestCase don't need manual $_SERVER restoration.
Learnt from: terabytesoftw
PR: yii2-extensions/psr-bridge#6
File: tests/http/RequestTest.php:1536-1552
Timestamp: 2025-07-20T16:35:15.341Z
Learning: In the yii2-extensions/psr-bridge project, the base TestCase class already handles $_SERVER cleanup in setUp() and tearDown() methods, so individual test methods that extend TestCase don't need manual $_SERVER restoration.
Learnt from: terabytesoftw
PR: yii2-extensions/psr-bridge#6
File: tests/http/RequestTest.php:1564-1578
Timestamp: 2025-07-20T16:33:57.495Z
Learning: The TestCase class in yii2-extensions/psr-bridge automatically handles $_SERVER superglobal cleanup by saving its original state before each test and restoring it afterward in setUp() and tearDown() methods. Manual $_SERVER cleanup in individual test methods is unnecessary when extending this TestCase.
🧬 Code Graph Analysis (1)
tests/http/StatelessApplicationTest.php (4)
tests/support/FactoryHelper.php (2)
FactoryHelper(46-268)createServerRequestCreator(154-161)tests/TestCase.php (1)
statelessApplication(106-174)src/http/ErrorHandler.php (1)
handleException(99-130)tests/http/ErrorHandlerTest.php (2)
testHandleExceptionWithUserException(295-319)ErrorHandlerTest(15-393)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: phpunit / PHP 8.4-windows-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
- GitHub Check: mutation / PHP 8.4-ubuntu-latest
🔇 Additional comments (1)
tests/http/StatelessApplicationTest.php (1)
13-13: LGTM - Appropriate imports addedThe imports for
UserExceptionandis_stringfunction are correctly added and necessary for the new test method.Also applies to: 35-35
…eption` handling in `ErrorHandler` class.
Summary by CodeRabbit