Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fmasa/php-vcr-matchers

Useful request matchers for php-vcr test HTTP recorder
https://github.com/fmasa/php-vcr-matchers

Last synced: 19 days ago
JSON representation

Useful request matchers for php-vcr test HTTP recorder

Awesome Lists containing this project

README

        

# Additional request matchers for PHP-VCR

## Installation
The best way to install fmasa/php-vcr-matchers is is using [Composer](https://getcomposer.org/):

```bash
composer require fmasa/php-vcr-matchers
```

## Avialable matchers

### BodyMatcherWithXpathExceptions

Tags matching XPath expression are ignored for comparison

Useful for matching XML requests with variable tags (such as nonce, or request time).

#### Usage

```php
\VCR\VCR::configure()
->addRequestMatcher(
'body',
new \Fmasa\VCR\Matchers\BodyMatcherWithXpathExceptions([
'//*[local-name() = "Nonce"]',
'//*[local-name() = "Created"]',
])
);
```

This will match request even when <Nonce> and <Created> tags do not match those in recorded request.

### QueryMatcherWithIgnoredParameters

Query parameters with specified names are ignored for comparison.

Useful for variable query parameters like timestamp or session ID.

#### Usage

```php
\VCR\VCR::configure()
->addRequestMatcher(
'query',
new \Fmasa\VCR\Matchers\QueryMatcherWithIgnoredParameters([
'timestamp',
])
)
```

This will match request even when timestamp parameter values are different.