-
Notifications
You must be signed in to change notification settings - Fork 56
Add "Mock responses in functional tests" part #220
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
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.
thanks a lot! good idea to document that here. i added some ideas to improve the readability.
can you please mention this section with a ..hint::
section in http://docs.php-http.org/en/latest/clients/mock-client.html to say that this client is also available as service when using symfony?
integrations/symfony-bundle.rst
Outdated
@@ -205,6 +205,7 @@ services are: | |||
* ``httplug.factory.guzzle6`` | |||
* ``httplug.factory.react`` | |||
* ``httplug.factory.socket`` | |||
* ``httplug.factory.mock`` (Install ``php-http/mock-client``first) |
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 you need a whitespace before the "first)" bit to make sphinx build this correctly
integrations/symfony-bundle.rst
Outdated
@@ -342,6 +343,30 @@ The only steps they need is ``require`` one of the adapter implementations in | |||
their projects ``composer.json`` and instantiating the ``HttplugBundle`` in | |||
their kernel. | |||
|
|||
Mock responses in functional tests |
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.
we use the convention of all caps in titles, this should be "Mock Responses In Functional Tests"
integrations/symfony-bundle.rst
Outdated
@@ -342,6 +343,30 @@ The only steps they need is ``require`` one of the adapter implementations in | |||
their projects ``composer.json`` and instantiating the ``HttplugBundle`` in | |||
their kernel. | |||
|
|||
Mock responses in functional tests | |||
`````````````````````````````````` | |||
To mock responses in your functional tests, proceed as follow: |
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.
s/proceed as follow/use the mock client factory in your test environement configuration/
integrations/symfony-bundle.rst
Outdated
my_awesome_client: | ||
factory: 'httplug.factory.mock' # replace factory | ||
|
||
And in your tests: |
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.
To mock a response in your tests, do:
integrations/symfony-bundle.rst
Outdated
|
||
// SomeWebTestCase.php | ||
$client = static::createClient(); | ||
// $client->disableReboot(); You might uncomment this if your client (BrowserKit) make multiple requests as kernel is rebooted on each request. |
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.
good idea to mention that!
lets say "If your test has the client (BrowserKit) make multiple requests, you need to disable reboot as the kernel is rebooted on each request." - and i would that put into a comment line above the commented out reboot.
integrations/symfony-bundle.rst
Outdated
@@ -342,6 +343,30 @@ The only steps they need is ``require`` one of the adapter implementations in | |||
their projects ``composer.json`` and instantiating the ``HttplugBundle`` in | |||
their kernel. | |||
|
|||
Mock responses in functional tests | |||
`````````````````````````````````` |
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.
can you please addd a paragraph here that mentions again that you need the separate mock client library, and cross-link that to the clients/mock-client doc?
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.
great, thanks a lot!
No description provided.