Skip to content

Implement reset #25

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

Merged
merged 1 commit into from
Jan 5, 2019
Merged

Implement reset #25

merged 1 commit into from
Jan 5, 2019

Conversation

adelplace
Copy link
Contributor

@adelplace adelplace commented Jul 6, 2018

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
Documentation
License MIT

What's in this PR?

Add the possiblity to reset the client

Why?

To avoid side effects when using the mock on multiple tests

Example Usage

$client = new Client();

$response = $this->createMock('Psr\Http\Message\ResponseInterface');
$client->addResponse($response);

$client->reset();
// responses and exceptions stacks are empty now

To Do

  • Documentation needed ?

Copy link
Contributor

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, seems we missed this merge request somehow. can you please rebase on the current master? i think the issues will go away then.

i wonder if clearResponses is the right approach though. i think we should call the method reset() and also reset $this->exceptions and default response and default exception. one test must not rely on another test to have set any of those.

@adelplace adelplace changed the title Implement clear responses Implement reset Jan 3, 2019
@adelplace
Copy link
Contributor Author

I made some changes, it should be better now

@dbu dbu merged commit 407890d into php-http:master Jan 5, 2019
@dbu
Copy link
Contributor

dbu commented Jan 5, 2019

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants