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.
74 lines
3.6 KiB
PHP
74 lines
3.6 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::factory(fn() => v::intType())->assert(true),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('`true` must be an integer')
|
|
->and($fullMessage)->toBe('- `true` must be an integer')
|
|
->and($messages)->toBe(['intType' => '`true` must be an integer']),
|
|
));
|
|
|
|
test('Inverted', catchAll(
|
|
fn() => v::not(v::factory(fn() => v::intType()))->assert(2),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('2 must not be an integer')
|
|
->and($fullMessage)->toBe('- 2 must not be an integer')
|
|
->and($messages)->toBe(['notIntType' => '2 must not be an integer']),
|
|
));
|
|
|
|
test('With created name, default', catchAll(
|
|
fn() => v::named('Wrapper', v::factory(fn() => v::named('Created', v::intType())))->assert(true),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Created must be an integer')
|
|
->and($fullMessage)->toBe('- Created must be an integer')
|
|
->and($messages)->toBe(['intType' => 'Created must be an integer']),
|
|
));
|
|
|
|
test('With wrapper name, default', catchAll(
|
|
fn() => v::named('Wrapper', v::factory(fn() => v::intType()))->assert(true),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Wrapper must be an integer')
|
|
->and($fullMessage)->toBe('- Wrapper must be an integer')
|
|
->and($messages)->toBe(['intType' => 'Wrapper must be an integer']),
|
|
));
|
|
|
|
test('With created name, inverted', catchAll(
|
|
fn() => v::named('Not', v::not(v::named('Wrapped', v::factory(fn() => v::named('Created', v::intType())))))->assert(2),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Created must not be an integer')
|
|
->and($fullMessage)->toBe('- Created must not be an integer')
|
|
->and($messages)->toBe(['notIntType' => 'Created must not be an integer']),
|
|
));
|
|
|
|
test('With wrapper name, inverted', catchAll(
|
|
fn() => v::named('Not', v::not(v::named('Wrapped', v::factory(fn() => v::intType()))))->assert(2),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Wrapped must not be an integer')
|
|
->and($fullMessage)->toBe('- Wrapped must not be an integer')
|
|
->and($messages)->toBe(['notIntType' => 'Wrapped must not be an integer']),
|
|
));
|
|
|
|
test('With not name, inverted', catchAll(
|
|
fn() => v::named('Not', v::not(v::factory(fn() => v::intType())))->assert(2),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Not must not be an integer')
|
|
->and($fullMessage)->toBe('- Not must not be an integer')
|
|
->and($messages)->toBe(['notIntType' => 'Not must not be an integer']),
|
|
));
|
|
|
|
test('With template, default', catchAll(
|
|
fn() => v::factory(fn() => v::intType())->assert(true, 'Factory lizards lounging like lords in the local lagoon'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Factory lizards lounging like lords in the local lagoon')
|
|
->and($fullMessage)->toBe('- Factory lizards lounging like lords in the local lagoon')
|
|
->and($messages)->toBe(['intType' => 'Factory lizards lounging like lords in the local lagoon']),
|
|
));
|