forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidatorAfterRuleTest.php
More file actions
49 lines (41 loc) · 1.12 KB
/
Copy pathValidatorAfterRuleTest.php
File metadata and controls
49 lines (41 loc) · 1.12 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
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Illuminate\Tests\Validation;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
use Illuminate\Validation\Validator;
use PHPUnit\Framework\TestCase;
class ValidatorAfterRuleTest extends TestCase
{
public function testAfterAcceptsArrayOfRules()
{
$validator = new Validator(new Translator(new ArrayLoader, 'en'), [], []);
$validator->after([
fn ($validator) => $validator->errors()->add('closure', 'true'),
new InvokableAfterRule,
new AfterMethodRule,
])->messages()->messages();
$this->assertSame([
'closure' => ['true'],
'invokableAfterRule' => ['true'],
'afterMethodRule' => ['true'],
], $validator->messages()->messages());
}
}
class InvokableAfterRule
{
public function __invoke($validator)
{
$validator->errors()->add('invokableAfterRule', 'true');
}
}
class AfterMethodRule
{
public function __invoke()
{
//
}
public function after($validator)
{
$validator->errors()->add('afterMethodRule', 'true');
}
}