Conditions | 1 |
Paths | 1 |
Total Lines | 218 |
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 | |||
27 | public function testGetTransitions() |
||
28 | { |
||
29 | $client = $this->prophesize(TrelloApiClient::class); |
||
30 | |||
31 | $cardId = '5cdfb33499236c320e7d772c'; |
||
32 | $cards = [ |
||
33 | 0 => |
||
34 | [ |
||
35 | 'id' => $cardId, |
||
36 | 'checkItemStates' => NULL, |
||
37 | 'closed' => false, |
||
38 | 'dateLastActivity' => '2019-05-24T09:14:46.660Z', |
||
39 | 'desc' => '', |
||
40 | 'descData' => NULL, |
||
41 | 'dueReminder' => NULL, |
||
42 | 'idBoard' => '5cdfb328cc5d0542a9bc5ce0', |
||
43 | 'idList' => '5cdfb33181899386ced12d14', |
||
44 | 'idMembersVoted' => [], |
||
45 | 'idShort' => 1, |
||
46 | 'idAttachmentCover' => NULL, |
||
47 | 'idLabels' => [], |
||
48 | 'manualCoverAttachment' => false, |
||
49 | 'name' => 'prima', |
||
50 | 'pos' => 196607, |
||
51 | 'shortLink' => 'jV1haDyb', |
||
52 | 'badges' => |
||
53 | [ |
||
54 | 'attachmentsByType' => |
||
55 | [ |
||
56 | 'trello' => |
||
57 | [ |
||
58 | 'board' => 0, |
||
59 | 'card' => 0, |
||
60 | ], |
||
61 | ], |
||
62 | 'location' => false, |
||
63 | 'votes' => 0, |
||
64 | 'viewingMemberVoted' => false, |
||
65 | 'subscribed' => false, |
||
66 | 'fogbugz' => '', |
||
67 | 'checkItems' => 0, |
||
68 | 'checkItemsChecked' => 0, |
||
69 | 'comments' => 0, |
||
70 | 'attachments' => 0, |
||
71 | 'description' => false, |
||
72 | 'due' => NULL, |
||
73 | 'dueComplete' => false, |
||
74 | ], |
||
75 | 'dueComplete' => false, |
||
76 | 'due' => NULL, |
||
77 | 'idChecklists' => [], |
||
78 | 'idMembers' => [], |
||
79 | 'labels' => [], |
||
80 | 'shortUrl' => 'https://trello.com/c/jV1haDyb', |
||
81 | 'subscribed' => false, |
||
82 | 'url' => 'https://trello.com/c/jV1haDyb/1-prima', |
||
83 | ] |
||
84 | ]; |
||
85 | |||
86 | $creationCard = [ |
||
87 | 0 => [ |
||
88 | 'id' => $cardId, |
||
89 | 'idMemberCreator' => '521dbcdd68ba6dec350040ff', |
||
90 | 'data' => [ |
||
91 | 'board' => [ |
||
92 | 'shortLink' => 'ZctgODOd', |
||
93 | 'name' => 'TEST', |
||
94 | 'id' => '5cdfb328cc5d0542a9bc5ce0' |
||
95 | ], |
||
96 | |||
97 | 'list' => [ |
||
98 | 'name' => 'ToDo', |
||
99 | 'id' => '5cdfb32f696b0a36d3186758' |
||
100 | ], |
||
101 | 'card' => [ |
||
102 | 'shortLink' => 'tZEJWg0V', |
||
103 | 'idShort' => '1', |
||
104 | 'name' => 'prima', |
||
105 | 'id' => $cardId |
||
106 | ] |
||
107 | ], |
||
108 | 'type' => 'createCard', |
||
109 | 'date' => '2019-05-17T06:45:04.392Z', |
||
110 | 'limits' => [], |
||
111 | 'memberCreator' => [ |
||
112 | 'id' => '521dbcdd68ba6dec350040ff', |
||
113 | 'avatarHash' => '3fab266d04a3f6f570b6a46606e133c0', |
||
114 | 'avatarUrl' => 'https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0', |
||
115 | 'fullName' => 'Alessandro Minoccheri', |
||
116 | 'idMemberReferrer' => '516a8b285b342af34f003c96', |
||
117 | 'initials' => 'AM' |
||
118 | ] |
||
119 | ] |
||
120 | ]; |
||
121 | |||
122 | $cardHistory = json_decode('[ |
||
123 | { |
||
124 | "id": "5ce7b60627e1bb5e0a8c60d1", |
||
125 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
126 | "data": { |
||
127 | "listAfter": { |
||
128 | "name": "DOne", |
||
129 | "id": "5cdfb33181899386ced12d14" |
||
130 | }, |
||
131 | "listBefore": { |
||
132 | "name": "Doing", |
||
133 | "id": "5cdfb3302e078d53fd5c01f8" |
||
134 | }, |
||
135 | "board": { |
||
136 | "shortLink": "ZctgODOd", |
||
137 | "name": "TEST", |
||
138 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
139 | }, |
||
140 | "card": { |
||
141 | "shortLink": "jV1haDyb", |
||
142 | "idShort": 1, |
||
143 | "name": "prima", |
||
144 | "id": "5cdfb33499236c320e7d772c", |
||
145 | "idList": "5cdfb33181899386ced12d14" |
||
146 | }, |
||
147 | "old": { |
||
148 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
149 | } |
||
150 | }, |
||
151 | "type": "updateCard", |
||
152 | "date": "2019-05-24T09:14:46.642Z", |
||
153 | "limits": {}, |
||
154 | "memberCreator": { |
||
155 | "id": "521dbcdd68ba6dec350040ff", |
||
156 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
157 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
158 | "fullName": "Alessandro Minoccheri", |
||
159 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
160 | "initials": "AM", |
||
161 | "nonPublic": {}, |
||
162 | "nonPublicAvailable": false, |
||
163 | "username": "alessandrominoccheri1" |
||
164 | } |
||
165 | }, |
||
166 | { |
||
167 | "id": "5cdfb33a2d9abb38dcaedbd8", |
||
168 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
169 | "data": { |
||
170 | "listAfter": { |
||
171 | "name": "Doing", |
||
172 | "id": "5cdfb3302e078d53fd5c01f8" |
||
173 | }, |
||
174 | "listBefore": { |
||
175 | "name": "ToDo", |
||
176 | "id": "5cdfb32f696b0a36d3186758" |
||
177 | }, |
||
178 | "board": { |
||
179 | "shortLink": "ZctgODOd", |
||
180 | "name": "TEST", |
||
181 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
182 | }, |
||
183 | "card": { |
||
184 | "shortLink": "jV1haDyb", |
||
185 | "idShort": 1, |
||
186 | "name": "prima", |
||
187 | "id": "5cdfb33499236c320e7d772c", |
||
188 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
189 | }, |
||
190 | "old": { |
||
191 | "idList": "5cdfb32f696b0a36d3186758" |
||
192 | } |
||
193 | }, |
||
194 | "type": "updateCard", |
||
195 | "date": "2019-05-18T07:24:42.415Z", |
||
196 | "limits": {}, |
||
197 | "memberCreator": { |
||
198 | "id": "521dbcdd68ba6dec350040ff", |
||
199 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
200 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
201 | "fullName": "Alessandro Minoccheri", |
||
202 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
203 | "initials": "AM", |
||
204 | "nonPublic": {}, |
||
205 | "nonPublicAvailable": false, |
||
206 | "username": "alessandrominoccheri1" |
||
207 | } |
||
208 | } |
||
209 | ]', true); |
||
210 | |||
211 | $boardId = 'boardId'; |
||
212 | |||
213 | $client->findAllCards($boardId)->willReturn($cards); |
||
214 | |||
215 | $client->findCreationCard($cardId)->willReturn($creationCard); |
||
216 | |||
217 | $client->findAllCardHistory($cardId)->willReturn($cardHistory); |
||
218 | |||
219 | $trelloBoard = new TrelloBoard($client->reveal(), $boardId); |
||
220 | |||
221 | $cycleTimes = $trelloBoard->getTransitions(); |
||
222 | |||
223 | $expected = [0 => [ |
||
224 | 'id' => '5cdfb33499236c320e7d772c', |
||
225 | 'title' => 'prima', |
||
226 | 'cycleTimes' => [ |
||
227 | 0 => [ |
||
228 | 'from' => 'Doing', |
||
229 | 'to' => 'DOne', |
||
230 | 'days' => '6', |
||
231 | 'name' => 'Doing_DOne' |
||
232 | ], |
||
233 | 1 => [ |
||
234 | 'from' => 'ToDo', |
||
235 | 'to' => 'Doing', |
||
236 | 'days' => '1', |
||
237 | 'name' => 'ToDo_Doing' |
||
238 | ] |
||
239 | ] |
||
240 | ] |
||
241 | ]; |
||
242 | |||
243 | $this->assertEquals($expected, $cycleTimes); |
||
244 | } |
||
410 | } |