mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 15:25:45 +01:00
This commit introduces REUSE compliance by annotating all files with SPDX information and placing the reused licences in the LICENSES folder. We additionally removed the docheader tool which is made obsolete by this change. The main LICENSE and copyright text of the project is now not under my personal name anymore, and it belongs to "The Respect Project Contributors" instead. This change restores author names to several files, giving the appropriate attribution for contributions.
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
/*
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
* SPDX-FileContributor: Henrique Moody <henriquemoody@gmail.com>
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Respect\Validation\Test\Stubs\CountableStub;
|
|
|
|
$input = 'http://www.google.com/search?q=respect.github.com';
|
|
|
|
test('https://github.com/Respect/Validation/issues/799 | #1', catchAll(
|
|
fn() => v::init()
|
|
->call(
|
|
[new CountableStub(1), 'count'],
|
|
v::arrayVal()->key('scheme', v::startsWith('https')),
|
|
)
|
|
->assert($input),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('1 must be an array value')
|
|
->and($fullMessage)->toBe(<<<'FULL_MESSAGE'
|
|
- 1 must pass all the rules
|
|
- 1 must be an array value
|
|
- `.scheme` must be present
|
|
FULL_MESSAGE)
|
|
->and($messages)->toBe([
|
|
'__root__' => '1 must pass all the rules',
|
|
'arrayVal' => '1 must be an array value',
|
|
'scheme' => '`.scheme` must be present',
|
|
]),
|
|
));
|
|
|
|
test('https://github.com/Respect/Validation/issues/799 | #2', catchAll(
|
|
fn() => v::init()
|
|
->call(
|
|
fn($url) => parse_url((string) $url),
|
|
v::arrayVal()->key('scheme', v::startsWith('https')),
|
|
)
|
|
->assert($input),
|
|
fn(string $message, string $fullMessage, array $messages) => expect()
|
|
->and($message)->toBe('`.scheme` must start with "https"')
|
|
->and($fullMessage)->toBe('- `.scheme` must start with "https"')
|
|
->and($messages)->toBe(['scheme' => '`.scheme` must start with "https"']),
|
|
));
|