mirror of
https://github.com/pestphp/pest.git
synced 2026-12-04 15:05:09 +01:00
e107ac707c
* Add default failure messages to the remaining string expectations * test: update parallel snapshot count for the new default-message cases --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Pest\Exceptions\InvalidExpectationValue;
|
|
use PHPUnit\Framework\ExpectationFailedException;
|
|
|
|
test('failures with wrong type', function (): void {
|
|
expect([])->toBeUlid();
|
|
})->throws(InvalidExpectationValue::class, 'This expectation may only be used on a value of type [string].');
|
|
|
|
test('pass', function (): void {
|
|
expect('01ARZ3NDEKTSV4RRFFQ69G5FAV')->toBeUlid()
|
|
->and('01BX5ZZKBKACTAV9WEVGEMMVRE')->toBeUlid()
|
|
->and('7ZZZZZZZZZ0000000000000000')->toBeUlid();
|
|
});
|
|
|
|
test('failures', function (): void {
|
|
expect('foo')->toBeUlid();
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('failures with message', function (): void {
|
|
expect('bar')->toBeUlid('oh no!');
|
|
})->throws(ExpectationFailedException::class, 'oh no!');
|
|
|
|
test('failures with default message', function (): void {
|
|
expect('foo')->toBeUlid();
|
|
})->throws(ExpectationFailedException::class, 'Failed asserting that foo is a ULID.');
|
|
|
|
test('not failures', function (): void {
|
|
expect('foo')->not->toBeUlid();
|
|
});
|