Passed
Pull Request — master (#72)
by Wilmer
12:57
created

EachTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 22
rs 10
wmc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Rule;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Validator\Rule\Each;
9
use Yiisoft\Validator\Rule\Number;
10
use Yiisoft\Validator\Rules;
11
12
/**
13
 * @group validators
14
 */
15
class EachTest extends TestCase
16
{
17
    /**
18
     * @test
19
     */
20
    public function validateValues(): void
21
    {
22
        $values = [
23
            10, 20, 30
24
        ];
25
26
        $rules = new Rules([
27
            (new Number())->max(13)
28
        ]);
29
30
        $result = (new Each($rules))->validate($values);
31
        $errors = $result->getErrors();
32
33
        $this->assertFalse($result->isValid());
34
        $this->assertCount(2, $errors);
35
        $this->assertContains('Value must be no greater than 13. 20 given.', $errors);
36
        $this->assertContains('Value must be no greater than 13. 30 given.', $errors);
37
    }
38
}
39