mirror of
https://github.com/Respect/Validation.git
synced 2026-03-15 14:55:44 +01:00
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.
42 lines
2 KiB
PHP
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('Default', catchAll(
|
|
fn() => v::betweenExclusive(1, 10)->assert(12),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('12 must be greater than 1 and less than 10')
|
|
->and($fullMessage)->toBe('- 12 must be greater than 1 and less than 10')
|
|
->and($messages)->toBe(['betweenExclusive' => '12 must be greater than 1 and less than 10']),
|
|
));
|
|
|
|
test('Inverted', catchAll(
|
|
fn() => v::not(v::betweenExclusive(1, 10))->assert(5),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('5 must not be greater than 1 or less than 10')
|
|
->and($fullMessage)->toBe('- 5 must not be greater than 1 or less than 10')
|
|
->and($messages)->toBe(['notBetweenExclusive' => '5 must not be greater than 1 or less than 10']),
|
|
));
|
|
|
|
test('With template', catchAll(
|
|
fn() => v::templated('Bewildered bees buzzed between blooming begonias', v::betweenExclusive(1, 10))->assert(12),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Bewildered bees buzzed between blooming begonias')
|
|
->and($fullMessage)->toBe('- Bewildered bees buzzed between blooming begonias')
|
|
->and($messages)->toBe(['betweenExclusive' => 'Bewildered bees buzzed between blooming begonias']),
|
|
));
|
|
|
|
test('With name', catchAll(
|
|
fn() => v::named('Range', v::betweenExclusive(1, 10))->assert(10),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Range must be greater than 1 and less than 10')
|
|
->and($fullMessage)->toBe('- Range must be greater than 1 and less than 10')
|
|
->and($messages)->toBe(['betweenExclusive' => 'Range must be greater than 1 and less than 10']),
|
|
));
|