respect-validation/tests/feature/AssertWithTemplatesTest.php
Henrique Moody 7c681fec66
Fix SPDX headers in all files
I ran the `bin/console spdx --fix` with different strategies for
different files. For most of the core classes, since they've been
drastically rebuilt, I've run it with the `git-blame` strategy, for for
the `src/Validators`, in which the API changed completely but the logic
remains the same, I use the `git-log` strategy.
2026-02-03 15:23:23 +01:00

42 lines
2 KiB
PHP

<?php
/*
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: (c) Respect Project Contributors
* SPDX-FileContributor: Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
*/
declare(strict_types=1);
test('Template as a string in the chain', catchAll(
fn() => v::templated('My string template in the chain', v::alwaysInvalid())->assert(1),
fn(string $message, string $fullMessage, array $messages) => expect()
->and($message)->toBe('My string template in the chain')
->and($fullMessage)->toBe('- My string template in the chain')
->and($messages)->toBe(['alwaysInvalid' => 'My string template in the chain']),
));
test('Template as an array in the chain', catchAll(
fn() => v::alwaysInvalid()->assert(1, ['alwaysInvalid' => 'My array template in the chain']),
fn(string $message, string $fullMessage, array $messages) => expect()
->and($message)->toBe('My array template in the chain')
->and($fullMessage)->toBe('- My array template in the chain')
->and($messages)->toBe(['alwaysInvalid' => 'My array template in the chain']),
));
test('Runtime template as string', catchAll(
fn() => v::alwaysInvalid()->assert(1, 'My runtime template as string'),
fn(string $message, string $fullMessage, array $messages) => expect()
->and($message)->toBe('My runtime template as string')
->and($fullMessage)->toBe('- My runtime template as string')
->and($messages)->toBe(['alwaysInvalid' => 'My runtime template as string']),
));
test('Runtime template as an array', catchAll(
fn() => v::alwaysInvalid()->assert(1, ['alwaysInvalid' => 'My runtime template an array']),
fn(string $message, string $fullMessage, array $messages) => expect()
->and($message)->toBe('My runtime template an array')
->and($fullMessage)->toBe('- My runtime template an array')
->and($messages)->toBe(['alwaysInvalid' => 'My runtime template an array']),
));