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