Passed
Push — master ( 3d68ab...428d4b )
by Abdala
05:31
created

RuleChainTest::test_it_can_validate_rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tests\CustomerGauge\Password;
4
5
use PHPUnit\Framework\TestCase;
6
use CustomerGauge\Password\Rule;
7
use CustomerGauge\Password\RuleChain;
8
9
class RuleChainTest extends TestCase
10
{
11
    public function test_it_can_validate_rules()
12
    {
13
        $rule = $this->createMock(Rule::class);
14
15
        $rule->expects($this->once())
16
            ->method('__invoke');
17
18
        $validate = new RuleChain($rule);
19
20
        $validate('password');
21
    }
22
23
    public function test_it_can_validate_callables()
24
    {
25
        $function = function() {};
26
27
        $customMethod = new FixtureCustomMethod;
28
29
        $rule = $this->createMock(Rule::class);
30
31
        $rule->expects($this->once())
32
            ->method('__invoke');
33
34
        $validate = new RuleChain(
35
            'is_string',
36
            $function,
37
            [$customMethod, 'customMethod'],
38
            $rule
39
        );
40
41
        $validate('password');
42
    }
43
}
44
45
class FixtureCustomMethod
46
{
47
    public function customMethod(string $value) : void
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
    }
50
}
51