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

feat: Refactor http client mock #86

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

temp
Copy link
Member

@temp temp commented Jan 27, 2025

No description provided.

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 80.83990% with 146 lines in your changes missing coverage. Please review.

Project coverage is 69.29%. Comparing base (47e0d3c) to head (6344030).
Report is 60 commits behind head on main.

Files with missing lines Patch % Lines
...HttpClientMock/Exception/NoMatchingMockRequest.php 0.00% 72 Missing ⚠️
src/HttpClientMock/RealRequest.php 31.66% 41 Missing ⚠️
src/HttpClientMock/RealRequestFactory.php 87.50% 10 Missing ⚠️
src/HttpClientMock/Exception/NoResponseMock.php 0.00% 8 Missing ⚠️
src/HttpClientMock/MockRequestBuilder.php 91.66% 7 Missing ⚠️
...lientMock/Exception/UriContainsQueryParameters.php 0.00% 2 Missing ⚠️
src/HttpClientMock/HttpClientMockTrait.php 91.66% 2 Missing ⚠️
src/HttpClientMock/Matcher/Hit.php 91.66% 2 Missing ⚠️
src/HttpClientMock/CallStack.php 50.00% 1 Missing ⚠️
src/HttpClientMock/Matcher/MultipartMatcher.php 97.43% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main      #86       +/-   ##
=============================================
+ Coverage     52.04%   69.29%   +17.24%     
- Complexity      537      757      +220     
=============================================
  Files            34       61       +27     
  Lines          1587     2273      +686     
=============================================
+ Hits            826     1575      +749     
+ Misses          761      698       -63     
Flag Coverage Δ
unittests 69.29% <80.83%> (+17.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@temp temp force-pushed the feat/refactor-http-client-mock branch 9 times, most recently from 91bd54d to 546dee4 Compare January 29, 2025 07:34
public function __toString(): string
{
return is_callable($this->method)
? 'callback(request.header) !== false'
Copy link
Contributor

Choose a reason for hiding this comment

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

request.method instead of request.header

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed


public function __construct(string $key, private mixed $value)
{
$this->key = strtolower($key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is request param key lowercased, but query param key not?

Copy link
Member Author

Choose a reason for hiding this comment

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

mistake - fixed


public function hasHeader(string $key): bool
{
return in_array($key, array_map('strtolower', array_keys($this->headers)));
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be more error safe to normalize header keys in the constructor so that they cannot be forgotten.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. only did it this way so the RealRequest toString call would print the headers in the same way they were provided. but it's safer this way.

@temp temp force-pushed the feat/refactor-http-client-mock branch from 546dee4 to 067c61a Compare January 30, 2025 07:41
@temp temp force-pushed the feat/refactor-http-client-mock branch 2 times, most recently from c7e51c2 to 8125287 Compare January 30, 2025 07:54
BREAKING CHANGE: Request matcher behaviour has changed for headers, queryParams, requestParams and multiparts
@temp temp force-pushed the feat/refactor-http-client-mock branch from 8125287 to 6344030 Compare January 30, 2025 08:02
@pl-github pl-github merged commit 65320d4 into brainbits:main Jan 30, 2025
5 checks passed
Copy link

🎉 This PR is included in version 7.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants