Passed
Push — master ( 7bee4d...457c92 )
by Sebastian
01:54
created

CliTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 32
dl 0
loc 63
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecuteSuccess() 0 17 2
A testExecuteFailure() 0 14 1
A testExecuteSuccessWithReplacements() 0 17 2
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace CaptainHook\App\Runner\Action;
11
12
use CaptainHook\App\Config\Options;
13
use CaptainHook\App\Runner\BaseTestRunner;
14
15
class CliTest extends BaseTestRunner
16
{
17
    /**
18
     * Tests Cli::execute
19
     */
20
    public function testExecuteSuccess(): void
21
    {
22
        if (\defined('PHP_WINDOWS_VERSION_MAJOR')) {
23
            $this->markTestSkipped('not tested on windows');
24
        }
25
26
        $args   = [];
27
        $io     = $this->getIOMock();
28
        $action = $this->getActionConfigMock();
29
        $cmd    = CH_PATH_FILES . '/bin/success';
30
31
        $io->expects($this->once())->method('getArguments')->willReturn($args);
32
        $io->expects($this->once())->method('write');
33
        $action->expects($this->once())->method('getAction')->willReturn($cmd);
34
35
        $cli = new Cli();
36
        $cli->execute($io, $action);
37
    }
38
39
    /**
40
     * Tests Cli::execute
41
     */
42
    public function testExecuteSuccessWithReplacements(): void
43
    {
44
        if (\defined('PHP_WINDOWS_VERSION_MAJOR')) {
45
            $this->markTestSkipped('not tested on windows');
46
        }
47
48
        $args   = ['file' => 'bin', 'mode' => 'success'];
49
        $io     = $this->getIOMock();
50
        $action = $this->getActionConfigMock();
51
        $cmd    = CH_PATH_FILES . '/{FILE}/{MODE}';
52
53
        $io->expects($this->once())->method('getArguments')->willReturn($args);
54
        $io->expects($this->once())->method('write');
55
        $action->expects($this->once())->method('getAction')->willReturn($cmd);
56
57
        $cli = new Cli();
58
        $cli->execute($io, $action);
59
    }
60
61
    /**
62
     * Tests Cli::execute
63
     */
64
    public function testExecuteFailure(): void
65
    {
66
        $this->expectException(\Exception::class);
67
68
        $args   = [];
69
        $io     = $this->getIOMock();
70
        $action = $this->getActionConfigMock();
71
        $cmd    = CH_PATH_FILES . '/bin/failure';
72
73
        $io->expects($this->once())->method('getArguments')->willReturn($args);
74
        $action->expects($this->once())->method('getAction')->willReturn($cmd);
75
76
        $cli = new Cli();
77
        $cli->execute($io, $action);
78
    }
79
}
80