Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 42 |
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 |
||
24 | public function testGetMilestoneIssues() : void |
||
25 | { |
||
26 | $this->issueFetcher->expects($this->once()) |
||
27 | ->method('fetchMilestoneIssues') |
||
28 | ->with('jwage', 'changelog-generator', '1.0') |
||
29 | ->willReturn([ |
||
30 | [ |
||
31 | 'number' => 1, |
||
32 | 'title' => 'Issue #1', |
||
33 | 'body' => 'Issue #1 Body', |
||
34 | 'html_url' => 'https://github.com/jwage/changelog-generator/issue/1', |
||
35 | 'user' => ['login' => 'jwage'], |
||
36 | 'labels' => [['name' => 'Enhancement']], |
||
37 | ], |
||
38 | [ |
||
39 | 'number' => 2, |
||
40 | 'title' => '[Bug] Issue #2', |
||
41 | 'body' => 'Issue #2 Body', |
||
42 | 'html_url' => 'https://github.com/jwage/changelog-generator/issue/2', |
||
43 | 'user' => ['login' => 'jwage'], |
||
44 | 'labels' => [['name' => 'Bug']], |
||
45 | ], |
||
46 | ]); |
||
47 | |||
48 | $issue1 = $this->createMock(Issue::class); |
||
49 | $issue2 = $this->createMock(Issue::class); |
||
50 | |||
51 | $this->issueFactory->expects($this->at(0)) |
||
52 | ->method('create') |
||
53 | ->with([ |
||
54 | 'number' => 1, |
||
55 | 'title' => 'Issue #1', |
||
56 | 'body' => 'Issue #1 Body', |
||
57 | 'html_url' => 'https://github.com/jwage/changelog-generator/issue/1', |
||
58 | 'user' => ['login' => 'jwage'], |
||
59 | 'labels' => [['name' => 'Enhancement']], |
||
60 | ]) |
||
61 | ->willReturn($issue1); |
||
62 | |||
63 | $this->issueFactory->expects($this->at(1)) |
||
64 | ->method('create') |
||
65 | ->with([ |
||
66 | 'number' => 2, |
||
67 | 'title' => '[Bug] Issue #2', |
||
68 | 'body' => 'Issue #2 Body', |
||
69 | 'html_url' => 'https://github.com/jwage/changelog-generator/issue/2', |
||
70 | 'user' => ['login' => 'jwage'], |
||
71 | 'labels' => [['name' => 'Bug']], |
||
72 | ]) |
||
73 | ->willReturn($issue2); |
||
74 | |||
75 | $issues = $this->issueRepository->getMilestoneIssues('jwage', 'changelog-generator', '1.0'); |
||
76 | |||
77 | self::assertCount(2, $issues); |
||
78 | self::assertSame($issue1, $issues[1]); |
||
79 | self::assertSame($issue2, $issues[2]); |
||
80 | } |
||
93 |