-
Notifications
You must be signed in to change notification settings - Fork 99
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
Cast federation payload explicilty to an object #686
base: main
Are you sure you want to change the base?
Conversation
Please add test then to avoid regressions in future |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #686 +/- ##
=======================================
Coverage 89.71% 89.71%
=======================================
Files 52 52
Lines 1322 1322
=======================================
Hits 1186 1186
Misses 136 136 ☔ View full report in Codecov by Sentry. |
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.
thank you for your PR ❤️
I agree with norkunas, can you add a test with an empty MultiSearchFederation to ensure it works all the time?
…hen you pass an empty MultiSearchFederation to the multiSearch function
…hen you pass an empty MultiSearchFederation to the multiSearch function
@thijskuilman not sure that we need a functional test here :) better would be to assert on that what was really passed to http client, because now a test without assertions doesn't prove anything |
IMHO we should a dev requirement for symfony/http-client, which allows easier testing than the guzzle. Then your test could look like this:
code is just an idea and is not validated :) |
Yeah, I agree that it seems a bit weird that no assertions are done in the test. However, the current test does prove that no exceptions are raised during the function call: if you'd revert the object casting, then the test fails because the Beside that: I agree that testing the HTTP client instead might be nice (or a better solution) as well! :) |
My point was that unit test will be faster than the functional one :) |
@@ -25,7 +25,7 @@ public function multiSearch(array $queries = [], ?MultiSearchFederation $federat | |||
|
|||
$payload = ['queries' => $body]; | |||
if (null !== $federation) { | |||
$payload['federation'] = $federation->toArray(); | |||
$payload['federation'] = (object) $federation->toArray(); |
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.
Why is typecasting necessary? You could use $payload['federation'] = $federation;
and it would work just fine.
@curquiza Could you please review and process this PR or provide a solution? This is an important update. |
I've already reviewed and my point still stands - it'd enough for unit test (current test does not do any assertion) |
Pull Request
Related issue
Fixes #685
What does this PR do?
federation
payload explicitly to an object. This solves the error that appears when noMultiSearchFederation
properties have been set.PR checklist
Please check if your PR fulfills the following requirements: