feat(expect): adds toHaveProperty

This commit is contained in:
Nuno Maduro
2020-07-14 23:37:02 +02:00
parent 32ef377284
commit 1aec8bac55
6 changed files with 42 additions and 34 deletions

View File

@ -0,0 +1,18 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
$obj = new stdClass();
$obj->foo = 'bar';
test('pass', function () use ($obj) {
expect($obj)->toHaveProperty('foo');
});
test('failures', function () use ($obj) {
expect($obj)->toHaveProperty('bar');
})->throws(ExpectationFailedException::class);
test('not failures', function () use ($obj) {
expect($obj)->not->toHaveProperty('foo');
})->throws(ExpectationFailedException::class);