Skip to content
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

Synchronize Query Parameters Between ServerRequest and Uri #63

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

butschster
Copy link
Member

@butschster butschster commented Oct 3, 2023

Within the FakeHttp class, developers can specify query strings in two ways:

  1. By embedding them directly in the URI:
$http->get('/some-uri/?foo=bar');
  1. By passing them as an associative array:
$http->get('/some-uri', ['foo' => 'bar']);

This flexibility, however, can lead to potential inconsistencies when both methods are used simultaneously. It's crucial to ensure coherency between the query parameters of the Psr\Http\Message\UriInterface class and the Psr\Http\Message\ServerRequestInterface class.

This PR modifies the createRequest method of the FakeHttp class to address this inconsistency:

  • It first checks if the Uri in ServerRequest has any query parameters.
  • If found, these parameters are merged with the ones provided to the createRequest method, ensuring a comprehensive and consistent set of query parameters.

- Merge URI query parameters with provided query params.
- Adjust `createRequest` method to ensure both Uri and ServerRequest objects have consistent query values.
@butschster butschster added the bug Something isn't working label Oct 3, 2023
@butschster butschster self-assigned this Oct 3, 2023
@butschster butschster added this to the 2.x milestone Oct 3, 2023
@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (c217343) 40.79% compared to head (c6bc5fd) 42.37%.
Report is 3 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x      #63      +/-   ##
============================================
+ Coverage     40.79%   42.37%   +1.57%     
- Complexity      310      319       +9     
============================================
  Files            33       33              
  Lines           956      977      +21     
============================================
+ Hits            390      414      +24     
+ Misses          566      563       -3     
Files Coverage Δ
src/Http/FakeHttp.php 34.04% <47.36%> (+0.21%) ⬆️

... and 1 file with indirect coverage changes

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

@butschster butschster merged commit fdbe8f0 into 2.x Oct 3, 2023
4 of 6 checks passed
@butschster butschster deleted the hotfix/promote-query-from-uri branch October 3, 2023 12:50
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.

None yet

1 participant