Passed
Push — master ( 813fe9...62056b )
by Sebastian
06:01
created

InstallerTest::testSetHookInvalid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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;
11
12
class InstallerTest extends BaseTestRunner
13
{
14
    /**
15
     * Tests Installer::setHook
16
     *
17
     * @expectedException \Exception
18
     */
19 View Code Duplication
    public function testSetHookInvalid()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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');
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<CaptainHook\App\Console\IO\DefaultIO>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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);
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<CaptainHook\App\Git\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
52
        $io->expects($this->once())->method('ask')->willReturn('no');
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<CaptainHook\App\Console\IO\DefaultIO>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
        $runner->writeHookFile('pre-push', true);
0 ignored issues
show
Unused Code introduced by
The call to Installer::writeHookFile() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
54
    }
55
}
56