Conditions | 1 |
Paths | 1 |
Total Lines | 70 |
Code Lines | 51 |
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 |
||
103 | public function testGenerateWithDate() : void |
||
104 | { |
||
105 | [$issue1, $issue2, $pullRequest1, $pullRequest2, $issueGroup, $milestoneIssues, $issueGroups] = $this->arrangeIssues(); |
||
106 | |||
107 | $changelogConfig = new ChangelogConfig(self::USER, self::REPOSITORY, self::MILESTONE, []); |
||
108 | $changelogConfig->setIncludeDate(true); |
||
109 | |||
110 | $this->issueRepository->expects(self::once()) |
||
111 | ->method('getMilestoneIssues') |
||
112 | ->with($changelogConfig) |
||
113 | ->willReturn($milestoneIssues); |
||
114 | |||
115 | $this->issueGrouper->expects(self::once()) |
||
116 | ->method('groupIssues') |
||
117 | ->with($milestoneIssues) |
||
118 | ->willReturn($issueGroups); |
||
119 | |||
120 | $issueGroup->expects(self::once()) |
||
121 | ->method('getName') |
||
122 | ->willReturn('Enhancement'); |
||
123 | |||
124 | $issueGroup->expects(self::once()) |
||
125 | ->method('getIssues') |
||
126 | ->willReturn([$issue1, $issue2]); |
||
127 | |||
128 | $issue1->expects(self::once()) |
||
129 | ->method('render') |
||
130 | ->willReturn('Issue #1'); |
||
131 | |||
132 | $issue1->expects(self::once()) |
||
133 | ->method('getUser') |
||
134 | ->willReturn('jwage'); |
||
135 | |||
136 | $issue2->expects(self::once()) |
||
137 | ->method('render') |
||
138 | ->willReturn('Issue #2'); |
||
139 | |||
140 | $issue2->expects(self::once()) |
||
141 | ->method('getUser') |
||
142 | ->willReturn('jwage'); |
||
143 | |||
144 | $pullRequest1->expects(self::any()) |
||
145 | ->method('isPullRequest') |
||
146 | ->willReturn(true); |
||
147 | |||
148 | $pullRequest1->expects(self::once()) |
||
149 | ->method('getUser') |
||
150 | ->willReturn('Ocramius'); |
||
151 | |||
152 | $pullRequest2->expects(self::any()) |
||
153 | ->method('isPullRequest') |
||
154 | ->willReturn(true); |
||
155 | |||
156 | $pullRequest2->expects(self::once()) |
||
157 | ->method('getUser') |
||
158 | ->willReturn('romanb'); |
||
159 | |||
160 | $output = $this->arrangeConsoleOutput(); |
||
161 | |||
162 | $output->expects(self::at(0)) |
||
163 | ->method('writeln') |
||
164 | ->with([ |
||
165 | '## 1.0 - [' . (new \DateTime('now'))->format($changelogConfig->getOption('dateFormat')) . ']', |
||
166 | '', |
||
167 | '- Total issues resolved: **2**', |
||
168 | '- Total pull requests resolved: **2**', |
||
169 | '- Total contributors: **3**', |
||
170 | ]); |
||
171 | |||
172 | $this->changelogGenerator->generate($changelogConfig, $output); |
||
173 | } |
||
225 |