CommitMsgProcessorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A itShouldDisableHook() 0 10 1
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