Added toBeList expectation

This commit is contained in:
Morten Harders
2024-05-21 08:13:20 +02:00
parent 303f4c0113
commit 55f6b5696e
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toBeList();
expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList();
});
test('failures', function () {
expect(null)->toBeList();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect(null)->toBeList('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect(['a', 'b', 'c'])->not->toBeList();
})->throws(ExpectationFailedException::class);