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

PersistRuleChainTest::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\PersistRuleChain;
8
use CustomerGauge\Password\Exception\InvalidPassword;
9
10
class PersistRuleChainTest extends TestCase
11
{
12
    public function test_it_can_validate_rules()
13
    {
14
        $rule = $this->createMock(Rule::class);
15
16
        $rule->expects($this->once())
17
            ->method('__invoke');
18
19
        $validate = new PersistRuleChain($rule);
20
21
        self::assertTrue($validate('password'));
22
    }
23
24
    public function test_it_returns_false_when_there_is_an_exception()
25
    {
26
        $rule = $this->createMock(Rule::class);
27
28
        $rule->method('__invoke')
29
            ->will($this->throwException(new InvalidPassword));
30
31
        $validate = new PersistRuleChain($rule);
32
33
        self::assertFalse($validate('password'));
34
    }
35
}
36