Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.

Add request as an argument #35

Closed
wants to merge 1 commit into from
Closed

Add request as an argument #35

wants to merge 1 commit into from

Conversation

GaryPEGEOT
Copy link

Add an optional request argument to allow programmatically generated response in tests for example (Like fetching a file based on request URI / path).

Add an optional request argument to allow programmatically generated response in tests for example.
@dbu
Copy link
Contributor

dbu commented Jan 4, 2018

changing the interface signature would be a BC break and require us to bump the major version.

can you explain a bit more why you need this? the idea of the response factory is to not need to bind to a specific psr 7 implementation. i think regular code would never pass the request into the factory, so i don't see how this would be useful. if your application does something with a request to create a response, it should implement that logic itself, and then use the factory to create the response object from the response data, i think.

@GaryPEGEOT
Copy link
Author

I would like to use the mock-client to fetch a file based on request URI and populate response body with the file content in my functional tests, to simulate webservices response. I can add response to the mock client, but doing it on each paths / request is a bit cumbersome.

@dbu
Copy link
Contributor

dbu commented Jan 4, 2018

you can add several responses to the mock client and it will return them in order (also exceptions if you need). this is not perfect as it assumes a sequence of requests which might be too much detail knowledge about your app but could work for some scenarios.

i think anything that goes beyond that should be done with your customer mock client implementation (for example php-http/mock-client#24)

thus i am -1 on merging this pull request. but thanks for contributing, don't let this discourage you from further contributing ;-)

@dbu dbu closed this Jan 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants