feat: adds toMatchArray

This commit is contained in:
Nuno Maduro
2020-11-23 21:26:02 +01:00
parent cdf0a38145
commit 7bea51fe09
3 changed files with 60 additions and 3 deletions

View File

@ -200,6 +200,11 @@
PASS Tests\Expect\toMatch
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toMatchArray
✓ pass
✓ failures
✓ not failures
PASS Tests\Expect\toMatchConstraint
@ -399,5 +404,5 @@
✓ depends run test only once
✓ depends works with the correct test name
Tests: 7 skipped, 235 passed
Tests: 7 skipped, 238 passed

View File

@ -0,0 +1,31 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
$this->user = [
'id' => 1,
'name' => 'Nuno',
'email' => 'enunomaduro@gmail.com',
];
});
test('pass', function () {
expect($this->user)->toMatchArray([
'name' => 'Nuno',
'email' => 'enunomaduro@gmail.com',
]);
});
test('failures', function () {
expect($this->user)->toMatchArray([
'name' => 'Not the same name',
'email' => 'enunomaduro@gmail.com',
]);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect($this->user)->not->toMatchArray([
'id' => 1,
]);
})->throws(ExpectationFailedException::class);