Passed
Push — master ( e6a12d...210e25 )
by Petr
08:06
created

SafeRulesTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4
1
<?php
2
3
use kalanis\kw_rules\Rules;
4
use kalanis\kw_rules\Exceptions\RuleException;
5
6
7
class SafeRulesTest extends CommonTestClass
8
{
9
    /**
10
     * @param string $key
11
     * @param string $expectedValue
12
     * @param string $checkValue
13
     * @param bool $gotResult
14
     * @throws RuleException
15
     * @dataProvider equalsProvider
16
     */
17
    public function testEqualsSafeBasic(string $key, string $expectedValue, string $checkValue, bool $gotResult): void
18
    {
19
        $data = new Rules\Safe\HashedBasicEquals();
20
        $data->setAgainstValue($expectedValue);
21
        $this->assertInstanceOf(Rules\ARule::class, $data);
22
        $mock = MockEntry::init($key, $checkValue);
23
        if (!$gotResult) $this->expectException(RuleException::class);
24
        $data->validate($mock);
25
    }
26
27
    /**
28
     * @param string $key
29
     * @param string $expectedValue
30
     * @param string $checkValue
31
     * @param bool $gotResult
32
     * @throws RuleException
33
     * @dataProvider equalsProvider
34
     */
35
    public function testEqualsSafeFunc(string $key, string $expectedValue, string $checkValue, bool $gotResult): void
36
    {
37
        $data = new Rules\Safe\HashedFuncEquals();
38
        $data->setAgainstValue($expectedValue);
39
        $this->assertInstanceOf(Rules\ARule::class, $data);
40
        $mock = MockEntry::init($key, $checkValue);
41
        if (!$gotResult) $this->expectException(RuleException::class);
42
        $data->validate($mock);
43
    }
44
}
45