-
Notifications
You must be signed in to change notification settings - Fork 123
Maximal test coverage for "ClientInterface" implementing classes #108
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
Maximal test coverage for "ClientInterface" implementing classes #108
Conversation
a47f610 to
32fc16c
Compare
|
I've decided to add some more tests in here, so please don't merge yet. |
32fc16c to
fd6516c
Compare
5ae0b19 to
f18e1a7
Compare
f18e1a7 to
6f6f152
Compare
|
@jpastoor , ready for review. |
|
Cool I'll check it out this weekend |
| } | ||
| elseif ( $method == 'PUT' ) { | ||
| curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); | ||
| elseif ( $method == 'PUT' || $method == 'DELETE' ) { |
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.
I think it would have been nicer to rebase & land #76 instead of putting it in your own code. (Especially since the rebase was needed due to a code style change you did yourself)
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.
That thought have crossed my mind, but I decided not to take that patch considering much more actions involved from my side.
Since you've asked I've created #115 now and once merged I can rebase this PR on top of it.
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.
Cool
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.
Rebased and pushed.
|
With this change we would introduce the need for a webserver to run the unit tests for this library. This makes it harder for potential contributers to run the unit test suite. I propose either |
In this case with option a. of above that would be mocking the actual curl_exec call so you can influence the outcome. You would wrap that call in an injectable class (pseudo code incoming)
and inject that in the CurlClient. You can ignore those lines explicitly from the coverage report. |
Ha, you've missed the whole point. Tests, that require Web Server only run, when
In the CONTRIBUTING.md I've mentioned |
Don't be CURL-oriented. We need solution that will cover all existing and further client classes. Somebody might want to create GuzzleClient class someday maybe and we need to see that it actually works, not that it works on our mocked |
6f6f152 to
df63fae
Compare
|
Woops that is pretty sweet then Alex. Did not see that they were already optional indeed. |
So please next time try to run test suite before trying to suggest workaround for non-existing problem. 😉 |
|
Still think it would be a nice abstraction the one I suggested. Makes for cleaner tests and easier input/output control. (You would not need to do it for guzzle since that has the abstraction build in already) |
As I've written above it's curl-oriented and we can't use it to test any client.
We have an abstraction too: the |
df63fae to
e1593c4
Compare
e1593c4 to
9dcb8d6
Compare
|
I've updated this part in |
Problems solved:
$dataparameter duringGETrequest value inCurlClientclass was made after it was passed intohttp_build_queryfunction call and that caused a notice$databeing an array duringGETrequest inPHPClientPHPClientwasn't sending correctContent-Typeheader, when makingGETrequestDELETEcalls inPHPClientCurlClientwere not working in PHP < 5.5 and HHVM (regression introduced in 96ab84e)CurlClientwere not working in PHP > 7.0 (regression introduced in 048d96d)PHPClientwas throwing different exceptions, thenCurlClientfor same HTTP responsesProblems not solved:
PHPClienttest that is getting HTTP 201 and HTTP 204 responses on HHVM 3.6.6 (Travis CI version) is failing for unknown reason. Locally I've tried on HHVM 3.13.1 and it works. I'm guessing this is HHVM bug.Also related to #100.