Files
pest/tests/Features/Expect/toBeAlphaNumeric.php
T
Vincent Borgers e107ac707c Add default failure messages to the remaining string expectations (#1948)
* 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>
2026-11-03 22:12:45 +05:30

27 lines
812 B
PHP

<?php
declare(strict_types=1);
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function (): void {
expect('abc123')->toBeAlphaNumeric()
->and('-')->not->toBeAlphaNumeric();
});
test('failures', function (): void {
expect('-')->toBeAlphaNumeric();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function (): void {
expect('-')->toBeAlphaNumeric('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('failures with default message', function (): void {
expect('-')->toBeAlphaNumeric();
})->throws(ExpectationFailedException::class, 'Failed asserting that - is alphanumeric.');
test('not failures', function (): void {
expect('abc123')->not->toBeAlphaNumeric();
})->throws(ExpectationFailedException::class);