Passed
Push — master ( dbf0a8...b29633 )
by
unknown
02:35
created

testDifferentRuleInHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Rule\Base;
6
7
use Yiisoft\Validator\Exception\UnexpectedRuleException;
8
use Yiisoft\Validator\Tests\Support\Rule\RuleWithCustomHandler;
9
use Yiisoft\Validator\Tests\Support\ValidatorFactory;
10
11
trait DifferentRuleInHandlerTestTrait
12
{
13
    public function testDifferentRuleInHandler(): void
14
    {
15
        [$ruleClassName, $ruleHandlerClassName] = $this->getDifferentRuleInHandlerItems();
16
17
        $rule = new RuleWithCustomHandler($ruleHandlerClassName);
18
        $validator = ValidatorFactory::make();
19
20
        $this->expectException(UnexpectedRuleException::class);
0 ignored issues
show
Bug introduced by
It seems like expectException() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

20
        $this->/** @scrutinizer ignore-call */ 
21
               expectException(UnexpectedRuleException::class);
Loading history...
21
        $this->expectExceptionMessage(
0 ignored issues
show
Bug introduced by
It seems like expectExceptionMessage() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

21
        $this->/** @scrutinizer ignore-call */ 
22
               expectExceptionMessage(
Loading history...
22
            'Expected "' . $ruleClassName . '", but ' . RuleWithCustomHandler::class . ' given.'
23
        );
24
        $validator->validate([], [$rule]);
25
    }
26
27
    /**
28
     * @return array{0:string, 1:string}
29
     */
30
    abstract protected function getDifferentRuleInHandlerItems(): array;
31
}
32