donatj / mock-webserver

Simple mock web server in PHP for unit testing.
MIT License
131 stars 21 forks source link

Alternate Method to Vary on Method #11

Closed donatj closed 6 years ago

donatj commented 6 years ago

Resolves #3 Replaces #8

Adds a ResponseByMethod response object that allows you to vary the response by given method.

donatj commented 6 years ago

@stevenrombauts I slept on it - and I have decided I'd rather handle varying by method with a new Response object.

The reasoning being in the future I'd like to be able to add other ways of varying responses as well. For example via GET parameters – which would resolve #6.

Adding a new optional method parameter every time I decide I want to vary on something isn't ideal.

Let me know if you have any objections, otherwise I will likely be merging and tagging this tonight.

I've kept your commits to acknowledge your contribution for which I am still quite grateful, and did kick the entire thing off ;)

donatj commented 6 years ago

You can see from the updated example how it would be used.

stevenrombauts commented 6 years ago

@donatj Nice, I like this approach much better, makes for cleaner code and adding more types of Response objects this way will make it much easier to extend in the future. Thanks and I'm sorry I gave you so much work today ;-)

donatj commented 6 years ago

@stevenrombauts Haha, no worries man - I'd been putting it off for WAY WAY too long.