🧪 Add edge case test for string error-codes in Response#609
Conversation
Added a new test case to `ResponseTest::provideJson` that ensures the `Response::fromJson` method handles invalid string `error-codes` by defaulting to `[ReCaptcha::E_UNKNOWN_ERROR]`. Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: The testing gap addressed
A missing edge case test for the
Responseclass whenerror-codesare passed as a string (e.g.,{"success": false, "error-codes": "bad-request"}) instead of the expected array format.📊 Coverage: What scenarios are now tested
The
ResponseTest::testFromJsonmethod now includes a scenario that verifies handling of stringerror-codesin the JSON response. Iferror-codesis not an array, the parser falls back to returning an array containingReCaptcha::E_UNKNOWN_ERROR, maintaining correct expected types.✨ Result: The improvement in test coverage
The test coverage now protects the explicit
is_array($responseData['error-codes'])type safety check inResponse::fromJson. It guarantees the code safely ignores invalid formats and handles the error gracefully without throwing type errors downstream.PR created automatically by Jules for task 3535967434115694764 started by @rowan-m