| Conditions | 1 |
| Paths | 1 |
| Total Lines | 57 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 26 | public function testGenerate() : void |
||
| 27 | { |
||
| 28 | $user = 'jwage'; |
||
| 29 | $repository = 'changelog-generator'; |
||
| 30 | $milestone = '1.0'; |
||
| 31 | |||
| 32 | $output = $this->createMock(OutputInterface::class); |
||
| 33 | |||
| 34 | $issue = $this->createMock(Issue::class); |
||
| 35 | $issueGroup = $this->createMock(IssueGroup::class); |
||
| 36 | |||
| 37 | $milestoneIssues = [$issue]; |
||
| 38 | $issueGroups = [$issueGroup]; |
||
| 39 | |||
| 40 | $this->issueRepository->expects($this->once()) |
||
| 41 | ->method('getMilestoneIssues') |
||
| 42 | ->with($user, $repository, $milestone) |
||
| 43 | ->willReturn($milestoneIssues); |
||
| 44 | |||
| 45 | $this->issueGrouper->expects($this->once()) |
||
| 46 | ->method('groupIssues') |
||
| 47 | ->with($milestoneIssues) |
||
| 48 | ->willReturn($issueGroups); |
||
| 49 | |||
| 50 | $issueGroup->expects($this->once()) |
||
| 51 | ->method('getName') |
||
| 52 | ->willReturn('Enhancement'); |
||
| 53 | |||
| 54 | $issueGroup->expects($this->once()) |
||
| 55 | ->method('getIssues') |
||
| 56 | ->willReturn([$issue]); |
||
| 57 | |||
| 58 | $issue->expects($this->once()) |
||
| 59 | ->method('render') |
||
| 60 | ->willReturn('Issue #1'); |
||
| 61 | |||
| 62 | $output->expects($this->at(0)) |
||
| 63 | ->method('writeln') |
||
| 64 | ->with([ |
||
| 65 | '## 1.0', |
||
| 66 | '', |
||
| 67 | 'Total issues resolved: **1**', |
||
| 68 | ]); |
||
| 69 | |||
| 70 | $output->expects($this->at(1)) |
||
| 71 | ->method('writeln') |
||
| 72 | ->with([ |
||
| 73 | '', |
||
| 74 | '### Enhancement', |
||
| 75 | '', |
||
| 76 | ]); |
||
| 77 | |||
| 78 | $output->expects($this->at(2)) |
||
| 79 | ->method('writeln') |
||
| 80 | ->with('Issue #1'); |
||
| 81 | |||
| 82 | $this->changelogGenerator->generate($user, $repository, $milestone, $output); |
||
| 83 | } |
||
| 96 |