Skip to content

Commit cc2c80b

Browse files
Add append text test
1 parent 9384557 commit cc2c80b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/unit/Hook/Message/Action/InjectIssueKeyFromBranchTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ public function testPrependSubject(): void
5353
$this->assertEquals('ABCD-12345 foo', $repo->getCommitMsg()->getSubject());
5454
}
5555

56+
/**
57+
* Tests InjectIssueKeyFromBranch::execute
58+
*
59+
* @throws \Exception
60+
*/
61+
public function testAppendSubject(): void
62+
{
63+
$repo = new RepoMock();
64+
$info = $this->createGitInfoOperator('5.0.0', 'freature/ABCD-12345-foo-bar-baz');
65+
66+
$repo->setCommitMsg(new CommitMessage('foo' . PHP_EOL . PHP_EOL . 'bar'));
67+
$repo->setInfoOperator($info);
68+
69+
$io = $this->createIOMock();
70+
$config = $this->createConfigMock();
71+
$action = $this->createActionConfigMock();
72+
$action->method('getOptions')->willReturn(new Options([
73+
'into' => 'subject',
74+
'mode' => 'append',
75+
]));
76+
77+
$hook = new InjectIssueKeyFromBranch();
78+
$hook->execute($config, $io, $repo, $action);
79+
80+
$this->assertEquals('foo ABCD-12345', $repo->getCommitMsg()->getSubject());
81+
}
82+
5683
/**
5784
* Tests InjectIssueKeyFromBranch::execute
5885
*

0 commit comments

Comments
 (0)