NotOnMatchingTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConditionFalse() 0 10 1
A testConditionTrue() 0 10 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook.
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Hook\Condition\Branch;
13
14
use PHPUnit\Framework\TestCase;
15
use CaptainHook\App\Console\IO\Mockery as IOMockery;
16
use CaptainHook\App\Mockery as AppMockery;
17
18
class NotOnMatchingTest extends TestCase
19
{
20
    use IOMockery;
21
    use AppMockery;
22
23
    public function testConditionFalse(): void
24
    {
25
        $io           = $this->createIOMock();
26
        $repository   = $this->createRepositoryMock();
27
        $infoOperator = $this->createGitInfoOperator('', 'feature/ABC-1234');
28
        $infoOperator->expects($this->once())->method('getCurrentBranch');
29
        $repository->expects($this->once())->method('getInfoOperator')->willReturn($infoOperator);
30
31
        $condition = new NotOnMatching('#feature/[A-Z0-9\\-_]+#i');
32
        $this->assertFalse($condition->isTrue($io, $repository));
33
    }
34
35
    public function testConditionTrue(): void
36
    {
37
        $io           = $this->createIOMock();
38
        $repository   = $this->createRepositoryMock();
39
        $infoOperator = $this->createGitInfoOperator();
40
        $infoOperator->expects($this->once())->method('getCurrentBranch')->willReturn('dev');
41
        $repository->expects($this->once())->method('getInfoOperator')->willReturn($infoOperator);
42
43
        $condition = new NotOnMatching('#feature/[a-z0-9\-_]+#i');
44
        $this->assertTrue($condition->isTrue($io, $repository));
45
    }
46
}
47