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

ConfigurationDataFinderQueryHandlerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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