CommitMsgProcessorTest::itShouldDisableHook()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Tests\Behaviour;
4
5
use PhpGitHooks\Module\Configuration\Service\CommitMsgProcessor;
6
use PhpGitHooks\Module\Configuration\Service\HookQuestions;
7
use PhpGitHooks\Module\Configuration\Tests\Infrastructure\ConfigurationUnitTestCase;
8
use PhpGitHooks\Module\Configuration\Tests\Stub\CommitMsgStub;
9
10
class CommitMsgProcessorTest extends ConfigurationUnitTestCase
11
{
12
    /**
13
     * @var CommitMsgProcessor
14
     */
15
    private $commitMsgProcessor;
16
17
    protected function setUp(): void
18
    {
19
        $this->commitMsgProcessor = new CommitMsgProcessor();
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function itShouldDisableHook()
26
    {
27
        $this->shouldAsk(HookQuestions::COMMIT_MSG_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER, 'n');
28
        
29
        $commitMsg = $this->commitMsgProcessor->process(CommitMsgStub::setUndefined(), $this->getIOInterface());
0 ignored issues
show
Bug introduced by
It seems like $this->getIOInterface() targeting PhpGitHooks\Module\Confi...Trait::getIOInterface() can also be of type object<Mockery\MockInterface>; however, PhpGitHooks\Module\Confi...MsgProcessor::process() does only seem to accept object<Composer\IO\IOInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
30
31
        $this->assertFalse($commitMsg->isUndefined());
32
        $this->assertFalse($commitMsg->isEnabled());
33
        $this->assertNull($commitMsg->getRegularExpression()->value());
34
    }
35
}
36