Completed
Push — master ( 8ee32e...efc44e )
by Pablo
02:33
created

ConfigurationDataFinderHandlerTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Tests\Behaviour;
4
5
use PhpGitHooks\Module\Configuration\Contract\Query\ConfigurationDataFinder;
6
use PhpGitHooks\Module\Configuration\Contract\Query\ConfigurationDataFinderHandler;
7
use PhpGitHooks\Module\Configuration\Contract\Response\ConfigurationDataResponse;
8
use PhpGitHooks\Module\Configuration\Tests\Infrastructure\ConfigurationUnitTestCase;
9
use PhpGitHooks\Module\Configuration\Tests\Stub\CommitMsgStub;
10
use PhpGitHooks\Module\Configuration\Tests\Stub\ConfigStub;
11
use PhpGitHooks\Module\Configuration\Tests\Stub\PreCommitStub;
12
use PhpGitHooks\Module\Configuration\Tests\Stub\PrePushStub;
13
14
class ConfigurationDataFinderHandlerTest extends ConfigurationUnitTestCase
15
{
16
    /**
17
     * @var ConfigurationDataFinderHandler
18
     */
19
    private $configurationDataFinderQueryHandler;
20
21
    protected function setUp()
22
    {
23
        $this->configurationDataFinderQueryHandler = new ConfigurationDataFinderHandler(
24
            $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...rHandler::__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...
25
        );
26
    }
27
28
    /**
29
     * @test
30
     */
31
    public function itShouldReturnEnabledTools()
32
    {
33
        $this->shouldReadConfigurationData(
34
            ConfigStub::create(
35
                PreCommitStub::createAllEnabled(),
36
                CommitMsgStub::createEnabled(),
37
                PrePushStub::createAllEnabled()
38
            )
39
        );
40
41
        /** @var ConfigurationDataResponse $data */
42
        $data = $this->configurationDataFinderQueryHandler->handle(new ConfigurationDataFinder());
43
44
        $this->assertTrue($data->getPreCommit()->isPreCommit());
45
        $this->assertNotNull($data->getPreCommit()->getRightMessage());
46
        $this->assertNotNull($data->getPreCommit()->getErrorMessage());
47
        $this->assertTrue($data->getPreCommit()->isComposer());
48
        $this->assertTrue($data->getPreCommit()->isJsonLint());
49
        $this->assertTrue($data->getPreCommit()->isPhpLint());
50
        $this->assertTrue($data->getPreCommit()->getPhpMd()->isPhpMd());
51
        $this->assertTrue($data->getPreCommit()->getPhpCs()->isPhpCs());
52
        $this->assertNotNull($data->getPreCommit()->getPhpCs()->getPhpCsStandard());
53
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixer());
54
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr0());
55
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr1());
56
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerPsr2());
57
        $this->assertTrue($data->getPreCommit()->getPhpCsFixer()->isPhpCsFixerSymfony());
58
        $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunit());
59
        $this->assertTrue($data->getPreCommit()->getPhpUnit()->isPhpunitRandomMode());
60
        $this->assertTrue($data->getPreCommit()->getPhpUnitGuardCoverage()->isEnabled());
61
        $this->assertNotNull($data->getPreCommit()->getPhpUnitGuardCoverage()->getWarningMessage());
62
        $this->assertNotNull($data->getPreCommit()->getPhpUnit()->getPhpunitOptions());
63
        $this->assertTrue($data->getCommitMsg()->isCommitMsg());
64
        $this->assertNotNull($data->getPrePush()->getPhpUnitGuardCoverage()->getWarningMessage());
65
    }
66
}
67