Files
pest/tests/Expect/toMatchArray.php
2020-11-23 21:26:02 +01:00

32 lines
724 B
PHP

<?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);