Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.4k
MockHandler - Add support to reset internal queue#2143
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ingluisjimenez commentedSep 13, 2018
@sagikazarmark@Nyholm Please let me know what do you think about this little feature, and whether this is the correct way of doing this or if there is a better way that maybe I'm not aware of. |
9e2dde8 to0ff5bf2Compare
Nyholm left a comment
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.
Thank you
0ff5bf2 tob67d0adCompareingluisjimenez commentedOct 22, 2019
rebased with latest from master |
ingluisjimenez commentedOct 23, 2019
Thank you for reviewing/merging! 🎉 |
Uh oh!
There was an error while loading.Please reload this page.
Actual Behavior
MockHandler doesn't offer a way of resetting the internal queue. There are testing scenarios where the handler has been initialized in the setUp() method of a test suite, to avoid duplication, and some specific responses are queued up as the default behavior but then you have tests which need to queue up something different (i.e a request error).
In this cases, it is not possible to reuse the handler defined in setUp(), and instad, it is required to re-instantiate and re-wire a handler and the dependencies all over again.
Expected Behavior
To avoid having to wire and set up the handler all over again, it would be great to expose a way to reset the internal queue in the MockHandler instance, and then just queue the new response(s).
This PR adds a method to MockHandler to reset the internal queue. Calling
$handler->reset();would reset the internal array and allow the tester to queue up new responses.