-
Notifications
You must be signed in to change notification settings - Fork 772
Expand file tree
/
Copy pathIssue1376Test.php
More file actions
38 lines (35 loc) · 1.5 KB
/
Issue1376Test.php
File metadata and controls
38 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
test('https://github.com/Respect/Validation/issues/1376', catchAll(
fn() => v::init()
->property('title', v::lengthBetween(2, 3)->stringType())
->property('description', v::stringType())
->property('author', v::intType()->lengthBetween(1, 2))
->property('user', v::intVal()->lengthBetween(1, 2))
->assert((object) ['author' => 'foo']),
fn(string $message, string $fullMessage, array $messages) => expect()
->and($message)->toBe('`.title` must be present')
->and($fullMessage)->toBe(<<<'FULL_MESSAGE'
- `stdClass { +$author="foo" }` must pass all the rules
- `.title` must be present
- `.description` must be present
- `.author` must pass all the rules
- `.author` must be an integer
- The length of `.author` must be between 1 and 2
- `.user` must be present
FULL_MESSAGE)
->and($messages)->toBe([
'__root__' => '`stdClass { +$author="foo" }` must pass all the rules',
'title' => '`.title` must be present',
'description' => '`.description` must be present',
'author' => [
'`.author` must be an integer',
'The length of `.author` must be between 1 and 2',
],
'user' => '`.user` must be present',
]),
));