Completed
Push — master ( 97e94f...81eace )
by Dmitriy
15s queued 13s
created

ValidatorInterfaceProxyTest::collectTestData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Debug;
6
7
use Yiisoft\Validator\Debug\ValidatorCollector;
8
use Yiisoft\Validator\Error;
9
use Yiisoft\Validator\Result;
10
use Yiisoft\Validator\Rule\Number;
11
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
12
use Yiisoft\Yii\Debug\Tests\Shared\AbstractCollectorTestCase;
13
14
final class ValidatorInterfaceProxyTest extends AbstractCollectorTestCase
15
{
16
    /**
17
     * @param CollectorInterface|ValidatorCollector $collector
18
     */
19
    protected function collectTestData(CollectorInterface|ValidatorCollector $collector): void
20
    {
21
        $collector->collect(1, (new Result())->addError('Too low', ['arg1' => 'v1']), [new Number(min: 7)]);
0 ignored issues
show
Bug introduced by
The method collect() does not exist on Yiisoft\Yii\Debug\Collector\CollectorInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\Yii\Debug\Collec...mmaryCollectorInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        $collector->/** @scrutinizer ignore-call */ 
22
                    collect(1, (new Result())->addError('Too low', ['arg1' => 'v1']), [new Number(min: 7)]);
Loading history...
22
        $collector->collect(10, new Result(), [new Number(min: 7)]);
23
    }
24
25
    protected function getCollector(): CollectorInterface
26
    {
27
        return new ValidatorCollector();
28
    }
29
30
    protected function checkCollectedData(array $data): void
31
    {
32
        parent::checkCollectedData($data);
33
34
        $this->assertEquals(
35
            [
36
                [
37
                    'value' => 1,
38
                    'rules' => [
39
                        new Number(min: 7),
40
                    ],
41
                    'result' => false,
42
                    'errors' => [
43
                        new Error('Too low', ['arg1' => 'v1']),
44
                    ],
45
                ],
46
                [
47
                    'value' => 10,
48
                    'rules' => [
49
                        new Number(min: 7),
50
                    ],
51
                    'result' => true,
52
                    'errors' => [],
53
                ],
54
            ],
55
            $data
56
        );
57
    }
58
59
    protected function checkIndexData(array $data): void
60
    {
61
        $this->assertEquals(
62
            ['total' => 2, 'valid' => 1, 'invalid' => 1],
63
            $data['validator']
64
        );
65
    }
66
}
67