File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,37 @@ Feature: Listing user toys
387
387
"""
388
388
```
389
389
390
+ ## PHPUnit integration
391
+
392
+ The ` assertMatchesPattern() ` is a handy assertion that matches values in PHPUnit tests.
393
+ To use it either include the ` Coduo\PHPMatcher\PHPUnit\PHPMatcherAssertions ` trait,
394
+ or extend the ` Coduo\PHPMatcher\PHPUnit\PHPMatcherTestCase ` :
395
+
396
+ ``` php
397
+ namespace Coduo\PHPMatcher\Tests\PHPUnit;
398
+
399
+ use Coduo\PHPMatcher\PHPUnit\PHPMatcherAssertions;
400
+
401
+ class PHPMatcherAssertionsTest extends \PHPUnit_Framework_TestCase
402
+ {
403
+ use PHPMatcherAssertions;
404
+
405
+ public function test_it_asserts_if_a_value_matches_the_pattern()
406
+ {
407
+ $this->assertMatchesPattern('@string@', 'foo');
408
+ }
409
+ }
410
+ ```
411
+
412
+ The ` matchesPattern() ` method can be used in PHPUnit stubs or mocks:
413
+
414
+ ``` php
415
+ $mock = $this->getMock(Foo::class);
416
+ $mock->method('bar')
417
+ ->with($this->matchesPattern('@string@'))
418
+ ->willReturn('foo');
419
+ ```
420
+
390
421
## License
391
422
392
423
This library is distributed under the MIT license. Please see the LICENSE file.
You can’t perform that action at this time.
0 commit comments