php$0 ➔ testGetOptionsWithNotRuleInternal()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 17
rs 9.7
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 InvalidArgumentException;
8
use Yiisoft\Validator\Rule\Number;
9
use Yiisoft\Validator\Rule\Required;
10
use Yiisoft\Validator\RuleInterface;
11
use Yiisoft\Validator\DumpedRuleInterface;
12
13
trait RuleWithProvidedRulesTrait
14
{
15
    abstract public function testGetOptionsWithNotRule(): void;
16
17
    private function testGetOptionsWithNotRuleInternal($ruleClassName): void
18
    {
19
        $rule = new $ruleClassName([
20
            new Required(),
21
            new class () {
22
            },
23
            new Number(min: 1),
24
        ]);
25
        $this->assertInstanceOf(DumpedRuleInterface::class, $rule);
0 ignored issues
show
Bug introduced by
It seems like assertInstanceOf() 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

25
        $this->/** @scrutinizer ignore-call */ 
26
               assertInstanceOf(DumpedRuleInterface::class, $rule);
Loading history...
26
27
        $this->expectException(InvalidArgumentException::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

27
        $this->/** @scrutinizer ignore-call */ 
28
               expectException(InvalidArgumentException::class);
Loading history...
28
29
        $ruleInterfaceName = RuleInterface::class;
30
        $message = "Rule must be either an instance of $ruleInterfaceName or a callable, class@anonymous given.";
31
        $this->expectExceptionMessage($message);
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

31
        $this->/** @scrutinizer ignore-call */ 
32
               expectExceptionMessage($message);
Loading history...
32
33
        $rule->getOptions();
34
    }
35
}
36