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.
50 lines
2.3 KiB
PHP
50 lines
2.3 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::templated('Template in "Templated"', v::stringType())->assert(12),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Template in "Templated"')
|
|
->and($fullMessage)->toBe('- Template in "Templated"')
|
|
->and($messages)->toBe(['stringType' => 'Template in "Templated"']),
|
|
));
|
|
|
|
test('With parameters', catchAll(
|
|
fn() => v::templated('Template in {{source}}', v::stringType(), ['source' => 'Templated'])->assert(12),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Template in "Templated"')
|
|
->and($fullMessage)->toBe('- Template in "Templated"')
|
|
->and($messages)->toBe(['stringType' => 'Template in "Templated"']),
|
|
));
|
|
|
|
test('Inverted', catchAll(
|
|
fn() => v::not(v::templated('Template in "Templated"', v::intType()))->assert(12),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Template in "Templated"')
|
|
->and($fullMessage)->toBe('- Template in "Templated"')
|
|
->and($messages)->toBe(['notIntType' => 'Template in "Templated"']),
|
|
));
|
|
|
|
test('Template passed to Validator::assert()', catchAll(
|
|
fn() => v::templated('Template in "Templated"', v::stringType())->assert(10, 'Template in "Validator::assert"'),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Template in "Validator::assert"')
|
|
->and($fullMessage)->toBe('- Template in "Validator::assert"')
|
|
->and($messages)->toBe(['stringType' => 'Template in "Validator::assert"']),
|
|
));
|
|
|
|
test('With bound', catchAll(
|
|
fn() => v::templated('Template in "Templated"', v::attributes())->assert(null),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('Template in "Templated"')
|
|
->and($fullMessage)->toBe('- Template in "Templated"')
|
|
->and($messages)->toBe(['attributes' => 'Template in "Templated"']),
|
|
));
|