Total Complexity | 2 |
Total Lines | 19 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class CallbackTest extends TestCase |
||
12 | { |
||
13 | public function testValidate(): void |
||
14 | { |
||
15 | $rule = new Callback( |
||
16 | static function ($value): Result { |
||
17 | $result = new Result(); |
||
18 | if ($value !== 42) { |
||
19 | $result->addError('Value should be 42!'); |
||
20 | } |
||
21 | return $result; |
||
22 | } |
||
23 | ); |
||
24 | |||
25 | $result = $rule->validate(41); |
||
26 | |||
27 | $this->assertFalse($result->isValid()); |
||
28 | $this->assertCount(1, $result->getErrors()); |
||
29 | $this->assertEquals('Value should be 42!', $result->getErrors()[0]); |
||
30 | } |
||
32 |