mirror of
https://github.com/pestphp/pest.git
synced 2026-03-09 17:27:22 +01:00
feat(expect): adds toHaveProperty
This commit is contained in:
18
tests/Expect/toHaveProperty.php
Normal file
18
tests/Expect/toHaveProperty.php
Normal 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);
|
||||
Reference in New Issue
Block a user