Skip to content

Conversation

@terabytesoftw
Copy link
Member

@terabytesoftw terabytesoftw commented Aug 25, 2025

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

Summary by CodeRabbit

  • Tests
    • Enhanced stateless HTTP test coverage by adding JSON body validations across multiple scenarios to ensure consistent responses.
    • Consolidated and simplified tests by removing a redundant case that duplicated status, header, and body checks.
    • No changes to runtime behavior or public APIs; these updates improve test reliability and clarity without affecting end-user functionality.

@terabytesoftw terabytesoftw added the bug Something isn't working label Aug 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

Adds JSON body assertions to multiple stateless HTTP core tests and removes a duplicate JSON response test from another test class. No production code or public API changes.

Changes

Cohort / File(s) Summary
Stateless HTTP core tests
tests/http/stateless/ApplicationCoreTest.php
Inserted JSON body equality checks (assertJsonStringEqualsJsonString) after Content-Type assertions in: testEventOrderDuringHandle, testResponseAdapterCachingAndResetBehaviorAcrossMultipleRequests, testSetsPsr7RequestWithStatelessAppStartTimeHeader, testSetWebAndWebrootAliasesAfterHandleRequest, testTriggerEventDuringHandle.
Stateless HTTP test cleanup
tests/http/stateless/ApplicationTest.php
Removed testReturnsJsonResponse(), which duplicated JSON response assertions now covered in core tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I sniffed the headers—crisp and bright,
Then nibbled payloads, JSON light.
Five hops through tests, each check in line,
One duplicate—removed, so fine.
With whiskers twitching, I assert with glee:
"Hello, world"—a tasty key! 🐇🧪

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-mini-127

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (580abf3) to head (e1bc621).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##                main      #146   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity       318       318           
===========================================
  Files             12        12           
  Lines            808       808           
===========================================
  Hits             808       808           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@terabytesoftw
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Aug 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (4)
tests/http/stateless/ApplicationCoreTest.php (4)

153-159: Same stream-safety nit: use (string)$response1->getBody() instead of getContents()

Aligns with the previous suggestion for consistent, side-effect-free assertions.

         self::assertJsonStringEqualsJsonString(
             <<<JSON
             {"hello":"world"}
             JSON,
-            $response1->getBody()->getContents(),
+            (string) $response1->getBody(),
             "Expected JSON Response body '{\"hello\":\"world\"}'.",
         );

357-363: Same improvement for body assertion

Replace getContents() to prevent cursor-related flakes.

         self::assertJsonStringEqualsJsonString(
             <<<JSON
             {"hello":"world"}
             JSON,
-            $response->getBody()->getContents(),
+            (string) $response->getBody(),
             "Expected JSON Response body '{\"hello\":\"world\"}'.",
         );

398-404: Same improvement for body assertion

Use string cast for reliability and consistency with other tests.

         self::assertJsonStringEqualsJsonString(
             <<<JSON
             {"hello":"world"}
             JSON,
-            $response->getBody()->getContents(),
+            (string) $response->getBody(),
             "Expected JSON Response body '{\"hello\":\"world\"}'.",
         );

451-457: Same improvement for body assertion

Avoid getContents() to prevent stream position surprises in future edits.

         self::assertJsonStringEqualsJsonString(
             <<<JSON
             {"hello":"world"}
             JSON,
-            $response->getBody()->getContents(),
+            (string) $response->getBody(),
             "Expected JSON Response body '{\"hello\":\"world\"}'.",
         );
🧹 Nitpick comments (1)
tests/http/stateless/ApplicationCoreTest.php (1)

118-124: Prefer casting the PSR-7 stream to string over getContents() to avoid pointer-side effects

getContents() reads from the current cursor; if anyone reads the body earlier (or later) the assertion can become flaky. Casting to string is safer for tests.

Apply this diff:

         self::assertJsonStringEqualsJsonString(
             <<<JSON
             {"hello":"world"}
             JSON,
-            $response->getBody()->getContents(),
+            (string) $response->getBody(),
             "Expected JSON Response body '{\"hello\":\"world\"}'.",
         );

Optional: to DRY repeated JSON body checks across tests, consider a small helper.

private static function assertJsonBody(string $expectedJson, \Psr\Http\Message\ResponseInterface $response): void
{
    self::assertJsonStringEqualsJsonString($expectedJson, (string) $response->getBody());
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 580abf3 and e1bc621.

📒 Files selected for processing (2)
  • tests/http/stateless/ApplicationCoreTest.php (5 hunks)
  • tests/http/stateless/ApplicationTest.php (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/http/stateless/ApplicationTest.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants