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

InstallerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 18.18 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 8
loc 44
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;
11
12
class InstallerTest extends BaseTestRunner
13
{
14
    /**
15
     * Tests Installer::setHook
16
     *
17
     * @expectedException \Exception
18
     */
19
    public function testSetHookInvalid()
20
    {
21
        $io     = $this->getIOMock();
22
        $config = $this->getConfigMock();
23
        $repo   = $this->getRepositoryMock();
24
        $runner = new Installer($io, $config, $repo);
25
        $runner->setHook('iDoNotExist');
26
    }
27
28
    /**
29
     * Tests Installer::installHook
30
     */
31
    public function testInstallHook()
32
    {
33
        $io     = $this->getIOMock();
34
        $config = $this->getConfigMock();
35
        $repo   = $this->getRepositoryMock();
36
        $runner = new Installer($io, $config, $repo);
37
        $io->expects($this->once())->method('ask')->willReturn('no');
38
        $runner->installHook('pre-push', true);
39
    }
40
41
42
    /**
43
     * Tests Installer::installHook
44
     */
45
    public function testWriteHookFile()
46
    {
47
        $io     = $this->getIOMock();
48
        $config = $this->getConfigMock();
49
        $repo   = $this->getRepositoryMock();
50
        $runner = new Installer($io, $config, $repo);
51
        $repo->expects($this->once())->method('hookExists')->willReturn(true);
52
        $io->expects($this->once())->method('ask')->willReturn('no');
53
        $runner->writeHookFile('pre-push', true);
54
    }
55
}
56