Passed
Pull Request — master (#41)
by Alexander
19:40 queued 04:42
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 Method

Rating   Name   Duplication   Size   Complexity  
A validateValues() 0 17 1
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
        $result = (new Each($rules))->validate($values);
28
        $errors = $result->getErrors();
29
30
        $this->assertFalse($result->isValid());
31
        $this->assertCount(2, $errors);
32
        $this->assertContains('Value must be no greater than 13. 20 given.', $errors);
33
        $this->assertContains('Value must be no greater than 13. 30 given.', $errors);
34
    }
35
}
36