Passed
Pull Request — master (#41)
by Alexander
10:28
created

EachTest::validateValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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