Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #218 from localheinz/fix/template
Browse files Browse the repository at this point in the history
Fix: Adjust template variable names
  • Loading branch information
localheinz authored Oct 25, 2017
2 parents bb0684d + 18866d3 commit 0e016a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/Console/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function configure()
't',
Input\InputOption::VALUE_REQUIRED,
'The template to use for rendering a pull request',
'- %title% (#%number%), by @%author%'
'- %pullrequest.title% (#%pullrequest.number%), by @%pullrequest.author.login%'
);
}

Expand Down Expand Up @@ -184,14 +184,16 @@ protected function execute(Input\InputInterface $input, Output\OutputInterface $
\array_walk($pullRequests, function (Resource\PullRequestInterface $pullRequest) use ($output, $template) {
$message = \str_replace(
[
'%title%',
'%number%',
'%author%',
'%pullrequest.title%',
'%pullrequest.number%',
'%pullrequest.author.login%',
'%pullrequest.author.htmlUrl%',
],
[
$pullRequest->title(),
$pullRequest->number(),
$pullRequest->author()->login(),
$pullRequest->author()->htmlUrl(),
],
$template
);
Expand Down
10 changes: 7 additions & 3 deletions test/Unit/Console/GenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function testExecuteRendersPullRequestsWithTemplate()

$pullRequests = $this->pullRequests($count);

$template = '- %title% (#%number%)';
$template = '- %pullrequest.title% (#pullrequest.%number%), submitted by [%pullrequest.author.login%](%pullrequest.author.htmlUrl%)';

$expectedMessages = [
\sprintf(
Expand All @@ -414,12 +414,16 @@ public function testExecuteRendersPullRequestsWithTemplate()
\array_walk($pullRequests, function (Resource\PullRequestInterface $pullRequest) use (&$expectedMessages, $template) {
$expectedMessages[] = \str_replace(
[
'%title%',
'%number%',
'%pullrequest.title%',
'%pullrequest.number%',
'%pullrequest.author.login%',
'%pullrequest.author.htmlUrl%',
],
[
$pullRequest->title(),
$pullRequest->number(),
$pullRequest->author()->login(),
$pullRequest->author()->htmlUrl(),
],
$template
);
Expand Down
2 changes: 1 addition & 1 deletion test/Util/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function providerGenerateCommandOption(): \Generator
't',
true,
'The template to use for rendering a pull request',
'- %title% (#%number%), by @%author%',
'- %pullrequest.title% (#%pullrequest.number%), by @%pullrequest.author.login%',
],
];

Expand Down

0 comments on commit 0e016a4

Please sign in to comment.