forked from bruli/php-git-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreCommitProcessorTest.php
More file actions
72 lines (62 loc) · 2.54 KB
/
PreCommitProcessorTest.php
File metadata and controls
72 lines (62 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace PhpGitHooks\Module\Configuration\Tests\Behaviour;
use Composer\IO\IOInterface;
use PhpGitHooks\Module\Configuration\Domain\Execute;
use PhpGitHooks\Module\Configuration\Domain\PhpUnit;
use PhpGitHooks\Module\Configuration\Domain\PhpUnitStrictCoverage;
use PhpGitHooks\Module\Configuration\Service\HookQuestions;
use PhpGitHooks\Module\Configuration\Service\PhpGuardCoverageGitIgnoreConfigurator;
use PhpGitHooks\Module\Configuration\Service\PhpUnitGuardCoverageConfigurator;
use PhpGitHooks\Module\Configuration\Service\PreCommitProcessor;
use PhpGitHooks\Module\Configuration\Tests\Infrastructure\ConfigurationUnitTestCase;
use PhpGitHooks\Module\Configuration\Tests\Stub\PreCommitStub;
class PreCommitProcessorTest extends ConfigurationUnitTestCase
{
/**
* @var PreCommitProcessor
*/
private $preCommitProcessor;
/**
* @var IOInterface
*/
private $io;
protected function setUp(): void
{
$this->io = $this->getIOInterface();
$this->preCommitProcessor = new PreCommitProcessor(
new PhpUnitGuardCoverageConfigurator(
new PhpGuardCoverageGitIgnoreConfigurator(
$this->getQueryBus(),
$this->getCommandBus()
)
)
);
}
/**
* @test
*/
public function itShouldDisablePreCommitHook()
{
$this->shouldAsk(HookQuestions::PRE_COMMIT_HOOK, HookQuestions::DEFAULT_TOOL_ANSWER, 'n');
$preCommitData = $this->preCommitProcessor->process(PreCommitStub::createUndefined(), $this->io);
$this->assertFalse($preCommitData->isEnabled());
$this->assertFalse($preCommitData->isUndefined());
$this->assertNull($preCommitData->getMessages()->getRightMessage()->value());
$this->assertNull($preCommitData->getMessages()->getErrorMessage()->value());
/** @var Execute $execute */
$execute = $preCommitData->getExecute();
$tools = $execute->execute();
$composer = $tools[0];
$jsonLint = $tools[1];
$phpLint = $tools[2];
/** @var PhpUnitStrictCoverage $phpunitStrictCoverage */
$phpunitStrictCoverage = $tools[7];
$this->assertFalse($composer->isEnabled());
$this->assertFalse($composer->isUndefined());
$this->assertFalse($jsonLint->isEnabled());
$this->assertFalse($jsonLint->isUndefined());
$this->assertFalse($phpLint->isEnabled());
$this->assertFalse($phpLint->isUndefined());
$this->assertFalse($phpunitStrictCoverage->isUndefined());
}
}