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() |
|
|
|
|
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
|
|
|
|
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.