mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
feat: move Expectations API out of external plugin
This commit is contained in:
22
tests/Features/Expect/toHaveProperty.php
Normal file
22
tests/Features/Expect/toHaveProperty.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->foo = 'bar';
|
||||
$obj->fooNull = null;
|
||||
|
||||
test('pass', function () use ($obj) {
|
||||
expect($obj)->toHaveProperty('foo');
|
||||
expect($obj)->toHaveProperty('foo', 'bar');
|
||||
expect($obj)->toHaveProperty('fooNull');
|
||||
expect($obj)->toHaveProperty('fooNull', null);
|
||||
});
|
||||
|
||||
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