Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Refactoring request matchers#266

Open
moufmouf wants to merge 51 commits intophp-vcr:masterfrom
moufmouf:request_matchers_interface
Open

Refactoring request matchers#266
moufmouf wants to merge 51 commits intophp-vcr:masterfrom
moufmouf:request_matchers_interface

Conversation

@moufmouf
Copy link
Contributor

@moufmouf moufmouf commented Jan 8, 2019

Context

This PR is a major refactoring of request matchers.
It introduces several breaking changes and should only be merged on a (future) 2.0 branch.

I tried to address a problem I faced with some advanced usage. Consider this:

In v1, the only way to do this is to create a custom request matcher that fulfills all these rules. Furthermore, some third party libraries (like the Symfony bundle) do not offer an easy way to add custom request matchers.

What has been done

This PR makes 2 major changes:

  • Request matchers are now objects implementing the RequestMatcherInterface rather than simple callbacks (this is for type safety)
  • Request matchers are stored in the cassette

By storing request matchers in the cassette, I can easily use different request matchers on different requests. This makes it easy to develop cassettes with advanced matching logic without going through the hassle of developing a custom request matcher.

Note

This PR is built on top of #259. While #259 does not introduce BC changes, this one is introducing (small) BC changes. DO NOT MERGE on v1 branch!

endorama and others added 30 commits October 18, 2017 14:59
cURL error is not forwarded correctly.
Add recording of curl infos
Headers now MUST be strings (no null value allowed in header).
Added HOST check in Request.
Tweaked some PHPDoc statements.
Added some ignore in PHPStan where assertions are already ensuring safety.
moufmouf and others added 21 commits October 29, 2018 20:29
Increasing minimum version to have support for Assertion::isResource.
It was not migrated to PHPUnit 7 yet because it was merged after the migration.
AbstractCodeTransform was actually misbehaving if several instances of the same XxxCodeTransform were to be created.
Indeed, a wrapper can be registered, but not unregistered. If 2 instances of CurlCodeTransform were to be created, the registration of the wrapper would be attempted twice. The second one would fail and try again but the wrapper is already registered. This PR registers only if the stream is indeed not already registered.
Was typehinted on the AbstractStorage class instead of the Storage interface.
Added SoapOperation request matcher + unit tests
This simplifies the code by removing the need to check for an array of request matcher (we can now use only one matcher)
@ValdoTR
Copy link
Contributor

ValdoTR commented Jan 8, 2019

God bless 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.

4 participants