Passed
Push — master ( 579314...f6d3c0 )
by Sebastian
02:05
created

OnBranchTest::testConditionTrue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 0
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;
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 OnBranchTest extends TestCase
19
{
20
    use IOMockery;
21
    use AppMockery;
22
23
    /**
24
     * Tests OnBranch::isTrue
25
     */
26
    public function testConditionTrue(): void
27
    {
28
        $io           = $this->createIOMock();
29
        $repository   = $this->createRepositoryMock();
30
        $infoOperator = $this->createGitInfoOperator();
31
        $infoOperator->expects($this->once())->method('getCurrentBranch')->willReturn('master');
32
        $repository->expects($this->once())->method('getInfoOperator')->willReturn($infoOperator);
33
34
        $condition = new OnBranch('master');
35
36
        $this->assertTrue($condition->isTrue($io, $repository));
37
    }
38
39
    /**
40
     * Tests OnBranch::isTrue
41
     */
42
    public function testConditionFalse(): void
43
    {
44
        $io           = $this->createIOMock();
45
        $repository   = $this->createRepositoryMock();
46
        $infoOperator = $this->createGitInfoOperator();
47
        $infoOperator->expects($this->once())->method('getCurrentBranch')->willReturn('master');
48
        $repository->expects($this->once())->method('getInfoOperator')->willReturn($infoOperator);
49
50
        $condition = new OnBranch('development');
51
52
        $this->assertFalse($condition->isTrue($io, $repository));
53
    }
54
}
55