Completed
Branch guard_coverage (f2aaf0)
by Pablo
03:07
created

ConfigurationDataFinderQueryHandlerTest   B

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 17

Importance

Changes 8
Bugs 1 Features 1
Metric Value
wmc 2
c 8
b 1
f 1
lcom 1
cbo 17
dl 0
loc 53
rs 7.8571

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
B itShouldReturnEnabledTools() 0 33 1
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Tests\Behaviour;
4
5
use PhpGitHooks\Module\Configuration\Contract\Query\ConfigurationDataFinderQuery;
6
use PhpGitHooks\Module\Configuration\Contract\QueryHandler\ConfigurationDataFinderQueryHandler;
7
use PhpGitHooks\Module\Configuration\Contract\Response\ConfigurationDataResponse;
8
use PhpGitHooks\Module\Configuration\Service\ConfigurationDataFinder;
9
use PhpGitHooks\Module\Configuration\Tests\Infrastructure\ConfigurationUnitTestCase;
10
use PhpGitHooks\Module\Configuration\Tests\Stub\CommitMsgStub;
11
use PhpGitHooks\Module\Configuration\Tests\Stub\ConfigStub;
12
use PhpGitHooks\Module\Configuration\Tests\Stub\PhpUnitGuardCoverageResponseStub;
13
use PhpGitHooks\Module\Configuration\Tests\Stub\PreCommitStub;
14
use PhpGitHooks\Module\Configuration\Tests\Stub\PrePushStub;
15
16
class ConfigurationDataFinderQueryHandlerTest extends ConfigurationUnitTestCase
17
{
18
    /**
19
     * @var ConfigurationDataFinderQueryHandler
20
     */
21
    private $configurationDataFinderQueryHandler;
22
23
    protected function setUp()
24
    {
25
        $this->configurationDataFinderQueryHandler = new ConfigurationDataFinderQueryHandler(
26
            new ConfigurationDataFinder(
27
                $this->getConfigurationFileReader()
0 ignored issues
show
Bug introduced by
It seems like $this->getConfigurationFileReader() targeting PhpGitHooks\Module\Confi...nfigurationFileReader() can also be of type object<Mockery\MockInterface>; however, PhpGitHooks\Module\Confi...taFinder::__construct() does only seem to accept object<PhpGitHooks\Modul...ionFileReaderInterface>, 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...
28
            )
29
        );
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function itShouldReturnEnabledTools()
36
    {
37
        $this->shouldReadConfigurationData(ConfigStub::create(
38
            PreCommitStub::createAllEnabled(),
39
            CommitMsgStub::createEnabled(),
40
            PrePushStub::createAllEnabled()
41
        ));
42
43
        /** @var ConfigurationDataResponse $data */
44
        $data = $this->configurationDataFinderQueryHandler->handle(new ConfigurationDataFinderQuery());
45
46
        $this->assertTrue($data->getPreCommit()->isPreCommit());
47
        $this->assertNotNull($data->getPreCommit()->getRightMessage());
48
        $this->assertNotNull($data->getPreCommit()->getErrorMessage());
49
        $this->assertTrue($data->getPreCommit()->isComposer());
50
        $this->assertTrue($data->getPreCommit()->isJsonLint());
51
        $this->assertTrue($data->getPreCommit()->isPhpLint());
52
        $this->assertTrue($data->getPreCommit()->getPhpMd()->isPhpMd());
53
        $this->assertTrue($data->getPreCommit()->getPhpCs()->isPhpCs());
54
        $this->assertNotNull($data->getPreCommit()->getPhpCs()->getPhpCsStandard());
55
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixer());
56
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0());
57
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1());
58
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2());
59
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony());
60
        $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunit());
61
        $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunitRandomMode());
62
        $this->assertTrue($data->getPreCommit()->getPhpUnitGuardCoverage()->isEnabled());
63
        $this->assertNotNull($data->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage());
64
        $this->assertNotNull($data->getPreCommit()->getPhpUnit()->getPhpunitOptions());
65
        $this->assertTrue($data->getCommitMsg()->isCommitMsg());
66
        $this->assertNotNull($data->getPrePush()->getPhpUnitGuardCoverage()->getWarningMessage());
67
    }
68
}
69