AdvancedTest::testConfigurePHPHook()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
nc 1
nop 0
dl 0
loc 17
rs 9.8666
c 1
b 0
f 0
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\Config\Setup;
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 AdvancedTest extends TestCase
20
{
21
    use ConfigMockery;
22
    use IOMockery;
23
    use CHMockery;
24
25
    public function testConfigureCliHook(): void
26
    {
27
        $invocations = $this->atLeast(3);
28
        $io          = $this->createIOMock();
29
        $config      = $this->createConfigMock();
30
        $config->expects($this->exactly(9))->method('getHookConfig')->willReturn($this->createHookConfigMock());
31
        $io->expects($invocations)
32
           ->method('ask')
33
           ->willReturnCallback(function ($parameters) use ($invocations) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

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

33
           ->willReturnCallback(function (/** @scrutinizer ignore-unused */ $parameters) use ($invocations) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
               $results = ['y', 'y', 'echo \'foo\'', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n'];
35
               return $results[$invocations->numberOfInvocations() - 1] ?? '';
36
           });
37
38
        $setup  = new Advanced($io);
39
        $setup->configureHooks($config);
40
    }
41
42
    public function testConfigurePHPHook(): void
43
    {
44
        $invocations = $this->atLeast(3);
45
        $io          = $this->createIOMock();
46
        $config      = $this->createConfigMock();
47
        $config->method('getHookConfig')->willReturn($this->createHookConfigMock());
48
        $io->expects($invocations)
49
           ->method('ask')
50
           ->willReturnCallback(function ($parameters) use ($invocations) {
0 ignored issues
show
Unused Code introduced by
The parameter $parameters is not used and could be removed. ( Ignorable by Annotation )

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

50
           ->willReturnCallback(function (/** @scrutinizer ignore-unused */ $parameters) use ($invocations) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
               $results = ['y', 'y', '\\Foo\\Bar', 'y', 'foo:bar', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n'];
52
               return $results[$invocations->numberOfInvocations() - 1] ?? '';
53
           });
54
55
        $io->expects($this->once())->method('askAndValidate')->willReturn('foo:bar');
56
57
        $setup  = new Advanced($io);
58
        $setup->configureHooks($config);
59
    }
60
}
61