SuccessTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecuteWithoutTags() 0 17 1
A testExecute() 0 16 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\Debug;
13
14
use CaptainHook\App\Config\Action;
15
use CaptainHook\App\Config\Mockery as ConfigMockery;
16
use CaptainHook\App\Console\IO\Mockery as IOMockery;
17
use CaptainHook\App\Hook\Debug;
18
use CaptainHook\App\Mockery as CHMockery;
19
use Exception;
20
use PHPUnit\Framework\TestCase;
21
use SebastianFeldmann\Git\Operator\Info;
22
23
class SuccessTest extends TestCase
24
{
25
    use ConfigMockery;
26
    use IOMockery;
27
    use CHMockery;
28
29
    /**
30
     * Tests Debug::execute
31
     *
32
     * @throws \Exception
33
     */
34
    public function testExecute(): void
35
    {
36
        $config       = $this->createConfigMock(true);
37
        $io           = $this->createIOMock();
38
        $repository   = $this->createRepositoryMock();
39
        $action       = new Action('\\' . Debug::class);
40
        $infoOperator = $this->createGitInfoOperator('1.0.0');
41
42
        $io->expects($this->once())->method('getArguments')->willReturn(['foo' => 'bar']);
43
        $io->expects($this->atLeast(3))->method('write');
44
        $repository->expects($this->exactly(1))->method('getInfoOperator')->willReturn($infoOperator);
45
46
        $debug = new Success();
47
        $debug->execute($config, $io, $repository, $action);
48
49
        $this->assertTrue(true);
50
    }
51
52
    /**
53
     * Tests Debug::execute
54
     */
55
    public function testExecuteWithoutTags(): void
56
    {
57
        $config       = $this->createConfigMock(true);
58
        $io           = $this->createIOMock();
59
        $repository   = $this->createRepositoryMock();
60
        $action       = new Action('\\' . Debug::class);
61
        $infoOperator = $this->getMockBuilder(Info::class)->disableOriginalConstructor()->getMock();
62
        $infoOperator->method('getCurrentTag')->willThrowException(new Exception('foo'));
63
64
        $io->expects($this->once())->method('getArguments')->willReturn(['foo' => 'bar']);
65
        $io->expects($this->atLeast(3))->method('write');
66
        $repository->expects($this->exactly(1))->method('getInfoOperator')->willReturn($infoOperator);
67
68
        $debug = new Success();
69
        $debug->execute($config, $io, $repository, $action);
70
71
        $this->assertTrue(true);
72
    }
73
}
74