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

RuleChainTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_it_can_validate_rules() 0 11 1
A test_it_can_validate_callables() 0 20 1
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