Passed
Push — master ( 21c505...12ca40 )
by Sebastian
02:34
created

CliTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 34.15 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 14
loc 41
c 0
b 0
f 0
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 sebastianfeldmann\CaptainHook\Runner\Action;
11
12
use sebastianfeldmann\CaptainHook\Runner\BaseTestRunner;
13
14
class CliTest extends BaseTestRunner
15
{
16
    /**
17
     * Tests Cli::execute
18
     */
19
    public function testExecuteSuccess()
20
    {
21
        $config = $this->getConfigMock();
22
        $io     = $this->getIOMock();
23
        $repo   = $this->getRepositoryMock();
24
        $action = $this->getActionConfigMock();
25
26
        $cmd = HMU_PATH_FILES . '/bin/success';
27
28
        $io->expects($this->once())->method('write');
29
        $action->expects($this->once())->method('getAction')->willReturn($cmd);
30
31
        $cli = new Cli();
32
        $cli->execute($config, $io, $repo, $action);
33
    }
34
35
    /**
36
     * Tests Cli::execute
37
     *
38
     * @expectedException \Exception
39
     */
40
    public function testExecuteFailure()
41
    {
42
        $config = $this->getConfigMock();
43
        $io     = $this->getIOMock();
44
        $repo   = $this->getRepositoryMock();
45
        $action = $this->getActionConfigMock();
46
47
        $cmd = HMU_PATH_FILES . '/bin/failure';
48
49
        $action->expects($this->once())->method('getAction')->willReturn($cmd);
50
51
        $cli = new Cli();
52
        $cli->execute($config, $io, $repo, $action);
53
    }
54
}
55