Passed
Push — main ( 394fb3...82ed03 )
by Sebastian
03:26
created

PostRewriteTest::testRunVirtualHookDisabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 30
rs 9.6666
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\Runner\Hook;
13
14
use CaptainHook\App\Config\Mockery as ConfigMockery;
15
use CaptainHook\App\Console\IO\Mockery as IOMockery;
16
use CaptainHook\App\Mockery as CHMockery;
17
use PHPUnit\Framework\TestCase;
18
19
class PostRewriteTest extends TestCase
20
{
21
    use ConfigMockery;
22
    use IOMockery;
23
    use CHMockery;
24
25
    /**
26
     * Tests PrePush::run
27
     *
28
     * @throws \Exception
29
     */
30
    public function testRunHookEnabled(): void
31
    {
32
        $io           = $this->createIOMock();
33
        $config       = $this->createConfigMock();
34
        $repo         = $this->createRepositoryMock();
35
        $hookConfig   = $this->createHookConfigMock();
36
37
        // configure the actually called hook
38
        $actionConfig = $this->createActionConfigMock();
39
        $hookConfig->method('getName')->willReturn('post-rewrite');
1 ignored issue
show
Bug introduced by
The method method() does not exist on CaptainHook\App\Config\Hook. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $hookConfig->/** @scrutinizer ignore-call */ 
40
                     method('getName')->willReturn('post-rewrite');

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...
40
        $hookConfig->method('isEnabled')->willReturn(true);
41
        $hookConfig->expects($this->once())->method('getActions')->willReturn([$actionConfig]);
42
43
        $config->expects($this->once())->method('getHookConfigToExecute')->willReturn($hookConfig);
44
        $config->expects($this->atLeastOnce())->method('isHookEnabled')->willReturn(true);
45
46
        $io->expects($this->atLeast(1))->method('write');
47
48
        $runner = new PostRewrite($io, $config, $repo);
49
        $runner->run();
50
    }
51
}
52