1
1
# PHP Matcher
2
2
3
- Library created for testing all kinds of JSON/XML/TXT/Scalar values against patterns.
3
+ Library created for testing all kinds of JSON/XML/TXT/Scalar values against patterns.
4
4
5
5
``` php
6
6
PHPMatcher::match($value = '{"foo": "bar"}', $pattern = '{"foo": "@string@"}');
7
7
```
8
8
9
- It was built to simplify API's functional testing.
9
+ It was built to simplify API's functional testing.
10
10
11
11
* [ ![ Build Status] ( https://travis-ci.org/coduo/php-matcher.svg )] ( https://travis-ci.org/coduo/php-matcher ) - master (3.2.* )
12
12
* [ ![ Build Status] ( https://travis-ci.org/coduo/php-matcher.svg?branch=3.1 )] ( https://travis-ci.org/coduo/php-matcher ) - 3.1.*
13
13
14
14
[ Readme for master (3.2) version] ( https://github.com/coduo/php-matcher/tree/master/README.md )
15
- [ Readme for 3.1 version] ( https://github.com/coduo/php-matcher/tree/3.1/README.md )
15
+ [ Readme for 3.1 version] ( https://github.com/coduo/php-matcher/tree/3.1/README.md )
16
16
17
17
18
18
## Installation
@@ -32,7 +32,7 @@ composer require --dev "coduo/php-matcher"
32
32
33
33
use Coduo\PHPMatcher\PHPMatcher;
34
34
35
- if (!PHPMatcher::match("lorem ipsum dolor", "@string@", $error)) {
35
+ if (!PHPMatcher::match("lorem ipsum dolor", "@string@", $error)) {
36
36
echo $error; // in case of error message is set on $error variable via reference
37
37
}
38
38
@@ -214,7 +214,7 @@ $matcher->match(array("bar"), "@wildcard@");
214
214
$matcher->match(new \stdClass, "@wildcard@");
215
215
```
216
216
217
- ### Expression matching
217
+ ### Expression matching
218
218
219
219
``` php
220
220
<?php
@@ -241,7 +241,7 @@ $matcher = $factory->createMatcher();
241
241
$matcher->match('9f4db639-0e87-4367-9beb-d64e3f42ae18', '@uuid@');
242
242
```
243
243
244
- ### Array matching
244
+ ### Array matching
245
245
246
246
``` php
247
247
<?php
@@ -296,11 +296,11 @@ $matcher->match(
296
296
),
297
297
'@boolean@',
298
298
'@double@'
299
- )
299
+ )
300
300
);
301
301
```
302
302
303
- ### Json matching
303
+ ### Json matching
304
304
305
305
``` php
306
306
<?php
@@ -452,7 +452,7 @@ Feature: Listing user toys
452
452
Scenario: Listing toys
453
453
Given the following users exist:
454
454
| firstName | lastName |
455
- | Chuck | Norris |
455
+ | Chuck | Norris |
456
456
457
457
And the following toys user "Chuck Norris" exist:
458
458
| name |
@@ -483,7 +483,7 @@ Feature: Listing user toys
483
483
}
484
484
]
485
485
"""
486
- ```
486
+ ```
487
487
488
488
## PHPUnit integration
489
489
@@ -495,8 +495,9 @@ or extend the `Coduo\PHPMatcher\PHPUnit\PHPMatcherTestCase`:
495
495
namespace Coduo\PHPMatcher\Tests\PHPUnit;
496
496
497
497
use Coduo\PHPMatcher\PHPUnit\PHPMatcherAssertions;
498
+ use PHPUnit\Framework\TestCase;
498
499
499
- class PHPMatcherAssertionsTest extends \PHPUnit_Framework_TestCase
500
+ class PHPMatcherAssertionsTest extends TestCase
500
501
{
501
502
use PHPMatcherAssertions;
502
503
@@ -510,7 +511,7 @@ class PHPMatcherAssertionsTest extends \PHPUnit_Framework_TestCase
510
511
The ` matchesPattern() ` method can be used in PHPUnit stubs or mocks:
511
512
512
513
``` php
513
- $mock = $this->getMock (Foo::class);
514
+ $mock = $this->createMock (Foo::class);
514
515
$mock->method('bar')
515
516
->with($this->matchesPattern('@string@'))
516
517
->willReturn('foo');
@@ -524,4 +525,3 @@ This library is distributed under the MIT license. Please see the LICENSE file.
524
525
525
526
This lib was inspired by [ JSON Expressions gem] ( https://github.com/chancancode/json_expressions ) &&
526
527
[ Behat RestExtension ] ( https://github.com/jakzal/RestExtension )
527
-
0 commit comments