-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Add HttpClientAssertionsTrait
which provide shortcuts to assert HTTP calls was triggered
#50662
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
Conversation
b8c4786
to
92b819c
Compare
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
3a2eb65
to
1d5c59b
Compare
I've update the examples in PR description. Now we allow assertion on a single URL (with method and optional body). I've added the opposition assertion |
1d5c59b
to
41dc300
Compare
HttpClientAssertionsTrait
which provide shortcut to assert HTTP calls was triggered
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
41398d8
to
cc86d41
Compare
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.
Random thoughts:
No need for checking headers using these?
Can't we remove the $client argument somehow? (don't we
8000
have it in the context somewhere?)
WHat about defaulting $httpClientId default to http_client
?
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
cc86d41
to
05f810c
Compare
Sure, I can add header checks 👍
We have access to this trait through
Nice idea |
28948b5
to
65e5d28
Compare
HttpClientAssertionsTrait
which provide shortcut to assert HTTP calls was triggeredHttpClientAssertionsTrait
which provide shortcuts to assert HTTP calls was triggered
a4e81ae
to
be5fc15
Compare
Same thoughts as Nicolas: if we can remove the need for the client arg and service name (when using the default), I think I’ll really dig it! |
@weaverryan it's done :) I've removed it https://github.com/symfony/symfony/pull/50662/files#diff-be0ff1fa989a87452ee0ecc8a932f09d50d59d3ecb4c6bce9565202aa254bd37R23. Through traits we have access to |
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
be5fc15
to
92bea53
Compare
src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php
Outdated
Show resolved
Hide resolved
4942a3f
to
ba7ab44
Compare
…cuts to assert HTTP calls was triggered
0b67973
to
59f5eec
Compare
Thank you @welcoMattic. |
…tation (welcoMattic) This PR was merged into the 6.4 branch. Discussion ---------- [FrameworkBundle] Add HttpClientAssertions trait documentation Ref symfony/symfony#50662 Commits ------- caa3483 Add HttpClientAssertions trait documentation
This PR brings a new collection (to enhance) of assertions to help users to ensure some HTTP calls has been triggered during a Request processing.
Example
An example is better than thousands words:
HttpClientAssertionsTest.php
FooController.php
http_client.yaml
This is a first try to improve DX in test, to allow users to assert more complex things (here it's HTTP calls, but I think also about adding assertions on logs for example).
Todo