Passed
Pull Request — master (#550)
by Alexander
05:42 queued 02:37
created

php$0 ➔ testGetOptionsWithNotRuleInternal()   A

Complexity

Conditions 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 18
rs 9.6666
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\RulesProviderInterface;
12
use Yiisoft\Validator\RuleWithOptionsInterface;
13
14
trait RuleWithProvidedRulesTrait
15
{
16
    abstract public function testGetOptionsWithNotRule(): void;
17
18
    private function testGetOptionsWithNotRuleInternal($ruleClassName): void
19
    {
20
        $rule = new $ruleClassName([
21
            new Required(),
22
            new class () {
23
            },
24
            new Number(min: 1),
25
        ]);
26
        $this->assertInstanceOf(RuleWithOptionsInterface::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

26
        $this->/** @scrutinizer ignore-call */ 
27
               assertInstanceOf(RuleWithOptionsInterface::class, $rule);
Loading history...
27
        $this->assertInstanceOf(RulesProviderInterface::class, $rule);
28
29
        $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

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

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