feat: add toBeUlid assertion and isUlid validation method (#1726)

This commit is contained in:
Sonali dudhia
2026-06-11 14:44:00 +05:30
committed by GitHub
parent 3d5bba93f8
commit 774a340400
3 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
use Pest\Exceptions\InvalidExpectationValue;
use PHPUnit\Framework\ExpectationFailedException;
test('failures with wrong type', function () {
expect([])->toBeUlid();
})->throws(InvalidExpectationValue::class, 'Invalid expectation value type. Expected [string].');
test('pass', function () {
expect('01ARZ3NDEKTSV4RRFFQ69G5FAV')->toBeUlid();
expect('01BX5ZZKBKACTAV9WEVGEMMVRE')->toBeUlid();
expect('7ZZZZZZZZZ0000000000000000')->toBeUlid();
});
test('failures', function () {
expect('foo')->toBeUlid();
})->throws(ExpectationFailedException::class);
test('failures with message', function () {
expect('bar')->toBeUlid('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect('foo')->not->toBeUlid();
});