forked from bruli/php-git-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommitMsgCommandHandlerTest.php
More file actions
57 lines (46 loc) · 1.84 KB
/
CommitMsgCommandHandlerTest.php
File metadata and controls
57 lines (46 loc) · 1.84 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
<?php
namespace PhpGitHooks\Module\Git\Tests\Behaviour;
use PhpGitHooks\Module\Configuration\Contract\Query\ConfigurationDataFinder;
use PhpGitHooks\Module\Configuration\Tests\Stub\ConfigurationDataResponseStub;
use PhpGitHooks\Module\Git\Contract\Command\CommitMsg;
use PhpGitHooks\Module\Git\Contract\Command\CommitMsgHandler;
use PhpGitHooks\Module\Git\Contract\Exception\InvalidCommitMessageException;
use PhpGitHooks\Module\Git\Service\CommitMsgTool;
use PhpGitHooks\Module\Git\Tests\Infrastructure\GitUnitTestCase;
class CommitMsgCommandHandlerTest extends GitUnitTestCase
{
/**
* @var CommitMsgHandler
*/
private $commitMsgCommandHandler;
protected function setUp(): void
{
$this->commitMsgCommandHandler = new CommitMsgHandler(
$this->getMergeValidator(),
$this->getQueryBus(),
$this->getCommitMessageFinder()
);
}
/**
* @test
*/
public function itShouldNotExecuteTool()
{
$configurationDataResponse = ConfigurationDataResponseStub::createCustom(true, false, false);
$this->shouldHandleQuery(new ConfigurationDataFinder(), $configurationDataResponse);
$this->commitMsgCommandHandler->handle(new CommitMsg($this->getInput()));
}
/**
* @test
*/
public function itShouldThrowsException()
{
$this->expectException(InvalidCommitMessageException::class);
$configurationDataResponse = ConfigurationDataResponseStub::createCustom(true, true, true);
$this->shouldHandleQuery(new ConfigurationDataFinder(), $configurationDataResponse);
$this->shouldGetInputFirstArgument('file');
$this->shouldFindCommitMessage('file', 'invalid commit message');
$this->shouldCallIsMerge(false);
$this->commitMsgCommandHandler->handle(new CommitMsg($this->getInput()));
}
}