respect-validation/tests/feature/Rules/CpfTest.php
2025-12-18 19:03:39 +01:00

28 lines
906 B
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
test('Scenario #1', catchMessage(
fn() => v::cpf()->assert('this thing'),
fn(string $message) => expect($message)->toBe('"this thing" must be a valid CPF number'),
));
test('Scenario #2', catchMessage(
fn() => v::not(v::cpf())->assert('276.865.775-11'),
fn(string $message) => expect($message)->toBe('"276.865.775-11" must not be a valid CPF number'),
));
test('Scenario #3', catchFullMessage(
fn() => v::cpf()->assert('your mother'),
fn(string $fullMessage) => expect($fullMessage)->toBe('- "your mother" must be a valid CPF number'),
));
test('Scenario #4', catchFullMessage(
fn() => v::not(v::cpf())->assert('61836182848'),
fn(string $fullMessage) => expect($fullMessage)->toBe('- "61836182848" must not be a valid CPF number'),
));