Skip to content

Add mock adapter implementation #1

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
Dec 29, 2015
Merged

Add mock adapter implementation #1

merged 1 commit into from
Dec 29, 2015

Conversation

ddeboer
Copy link
Contributor

@ddeboer ddeboer commented Dec 29, 2015

No description provided.

public function clear()
{
$this->exception = null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we just remove the clear() method and document that users can always create a new Mock adapter if they want to set different mock exceptions or responses?

Copy link
Member

Choose a reason for hiding this comment

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

I think symfony's similar client implementation can also be created on demand, so a clear method is probably not necessary.

@ddeboer
Copy link
Contributor Author

ddeboer commented Dec 29, 2015

Of course, this mock-adapter doesn’t really adapt anything so isn’t really an adapter. Is that a problem? Does this need to be renamed to mock-client instead?

@sagikazarmark
Copy link
Member

I think we originally planned it to be mock-client, not sure why it ended up as an adapter.

@sagikazarmark
Copy link
Member

You can rename the package and the repository, I will remove the old package from packagist and readd it as soon as this gets merged.

/**
* {@inheritdoc}
*/
public function sendRequest(RequestInterface $request)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sagikazarmark What is the recommended way: implement sendRequest() with HttpAsyncClientEmulator or implement sendAsyncRequest() with HttpClientEmulator?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it really matters in this case. It is probably fine this way. Since we don't need async by the nature of this client, using async first would mean you have to convert responses to promise first, and then convert back. This way we only need one conversion.

ddeboer added a commit that referenced this pull request Dec 29, 2015
Add mock adapter implementation
@ddeboer ddeboer merged commit 6c87bb3 into master Dec 29, 2015
@ddeboer ddeboer deleted the implementation branch December 29, 2015 17:26
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