mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: add support for toHaveMethod and toHaveMethods
This commit is contained in:
30
tests/Features/Expect/toHaveMethods.php
Normal file
30
tests/Features/Expect/toHaveMethods.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
$object = new class
|
||||
{
|
||||
public function foo(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function bar(): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
test('pass', function () use ($object) {
|
||||
expect($object)->toHaveMethods(['foo', 'bar']);
|
||||
});
|
||||
|
||||
test('failures', function () use ($object) {
|
||||
expect($object)->toHaveMethods(['foo', 'bar', 'baz']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () use ($object) {
|
||||
expect($object)->toHaveMethods(['foo', 'bar', 'baz'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () use ($object) {
|
||||
expect($object)->not->toHaveMethods(['foo', 'bar']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
Reference in New Issue
Block a user