Conditions | 1 |
Paths | 1 |
Total Lines | 164 |
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 |
||
246 | public function testGetCardTransitions() |
||
247 | { |
||
248 | $client = $this->prophesize(TrelloApiClient::class); |
||
249 | |||
250 | $id = '5cdfb33499236c320e7d772c'; |
||
251 | |||
252 | $creationCard = [ |
||
253 | 0 => [ |
||
254 | 'id' => $id, |
||
255 | 'idMemberCreator' => '521dbcdd68ba6dec350040ff', |
||
256 | 'data' => [ |
||
257 | 'board' => [ |
||
258 | 'shortLink' => 'ZctgODOd', |
||
259 | 'name' => 'TEST', |
||
260 | 'id' => '5cdfb328cc5d0542a9bc5ce0' |
||
261 | ], |
||
262 | |||
263 | 'list' => [ |
||
264 | 'name' => 'ToDo', |
||
265 | 'id' => '5cdfb32f696b0a36d3186758' |
||
266 | ], |
||
267 | 'card' => [ |
||
268 | 'shortLink' => 'tZEJWg0V', |
||
269 | 'idShort' => '1', |
||
270 | 'name' => 'prima', |
||
271 | 'id' => $id |
||
272 | ] |
||
273 | ], |
||
274 | 'type' => 'createCard', |
||
275 | 'date' => '2019-05-17T06:45:04.392Z', |
||
276 | 'limits' => [], |
||
277 | 'memberCreator' => [ |
||
278 | 'id' => '521dbcdd68ba6dec350040ff', |
||
279 | 'avatarHash' => '3fab266d04a3f6f570b6a46606e133c0', |
||
280 | 'avatarUrl' => 'https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0', |
||
281 | 'fullName' => 'Alessandro Minoccheri', |
||
282 | 'idMemberReferrer' => '516a8b285b342af34f003c96', |
||
283 | 'initials' => 'AM' |
||
284 | ] |
||
285 | ] |
||
286 | ]; |
||
287 | |||
288 | |||
289 | $cardHistory = json_decode('[ |
||
290 | { |
||
291 | "id": "5ce7b60627e1bb5e0a8c60d1", |
||
292 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
293 | "data": { |
||
294 | "listAfter": { |
||
295 | "name": "DOne", |
||
296 | "id": "5cdfb33181899386ced12d14" |
||
297 | }, |
||
298 | "listBefore": { |
||
299 | "name": "Doing", |
||
300 | "id": "5cdfb3302e078d53fd5c01f8" |
||
301 | }, |
||
302 | "board": { |
||
303 | "shortLink": "ZctgODOd", |
||
304 | "name": "TEST", |
||
305 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
306 | }, |
||
307 | "card": { |
||
308 | "shortLink": "jV1haDyb", |
||
309 | "idShort": 1, |
||
310 | "name": "prima", |
||
311 | "id": "5cdfb33499236c320e7d772c", |
||
312 | "idList": "5cdfb33181899386ced12d14" |
||
313 | }, |
||
314 | "old": { |
||
315 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
316 | } |
||
317 | }, |
||
318 | "type": "updateCard", |
||
319 | "date": "2019-05-24T09:14:46.642Z", |
||
320 | "limits": {}, |
||
321 | "memberCreator": { |
||
322 | "id": "521dbcdd68ba6dec350040ff", |
||
323 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
324 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
325 | "fullName": "Alessandro Minoccheri", |
||
326 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
327 | "initials": "AM", |
||
328 | "nonPublic": {}, |
||
329 | "nonPublicAvailable": false, |
||
330 | "username": "alessandrominoccheri1" |
||
331 | } |
||
332 | }, |
||
333 | { |
||
334 | "id": "5cdfb33a2d9abb38dcaedbd8", |
||
335 | "idMemberCreator": "521dbcdd68ba6dec350040ff", |
||
336 | "data": { |
||
337 | "listAfter": { |
||
338 | "name": "Doing", |
||
339 | "id": "5cdfb3302e078d53fd5c01f8" |
||
340 | }, |
||
341 | "listBefore": { |
||
342 | "name": "ToDo", |
||
343 | "id": "5cdfb32f696b0a36d3186758" |
||
344 | }, |
||
345 | "board": { |
||
346 | "shortLink": "ZctgODOd", |
||
347 | "name": "TEST", |
||
348 | "id": "5cdfb328cc5d0542a9bc5ce0" |
||
349 | }, |
||
350 | "card": { |
||
351 | "shortLink": "jV1haDyb", |
||
352 | "idShort": 1, |
||
353 | "name": "prima", |
||
354 | "id": "5cdfb33499236c320e7d772c", |
||
355 | "idList": "5cdfb3302e078d53fd5c01f8" |
||
356 | }, |
||
357 | "old": { |
||
358 | "idList": "5cdfb32f696b0a36d3186758" |
||
359 | } |
||
360 | }, |
||
361 | "type": "updateCard", |
||
362 | "date": "2019-05-18T07:24:42.415Z", |
||
363 | "limits": {}, |
||
364 | "memberCreator": { |
||
365 | "id": "521dbcdd68ba6dec350040ff", |
||
366 | "avatarHash": "3fab266d04a3f6f570b6a46606e133c0", |
||
367 | "avatarUrl": "https://trello-avatars.s3.amazonaws.com/3fab266d04a3f6f570b6a46606e133c0", |
||
368 | "fullName": "Alessandro Minoccheri", |
||
369 | "idMemberReferrer": "516a8b285b342af34f003c96", |
||
370 | "initials": "AM", |
||
371 | "nonPublic": {}, |
||
372 | "nonPublicAvailable": false, |
||
373 | "username": "alessandrominoccheri1" |
||
374 | } |
||
375 | } |
||
376 | ]', true); |
||
377 | |||
378 | $boardId = 'boardId'; |
||
379 | |||
380 | $client->findCreationCard($id)->willReturn($creationCard); |
||
381 | |||
382 | $client->findAllCardHistory($id)->willReturn($cardHistory); |
||
383 | |||
384 | $trelloBoard = new TrelloBoard($client->reveal(), $boardId); |
||
385 | |||
386 | $cycleTimes = $trelloBoard->getCardTransitions($id); |
||
387 | |||
388 | $expected = [0 => [ |
||
389 | 'id' => $id, |
||
390 | 'title' => 'prima', |
||
391 | 'cycleTimes' => [ |
||
392 | 0 => [ |
||
393 | 'from' => 'Doing', |
||
394 | 'to' => 'DOne', |
||
395 | 'days' => '6', |
||
396 | 'name' => 'Doing_DOne' |
||
397 | ], |
||
398 | 1 => [ |
||
399 | 'from' => 'ToDo', |
||
400 | 'to' => 'Doing', |
||
401 | 'days' => '1', |
||
402 | 'name' => 'ToDo_Doing' |
||
403 | ] |
||
404 | ] |
||
405 | ] |
||
406 | ]; |
||
407 | |||
408 | $this->assertEquals($expected, $cycleTimes); |
||
409 | } |
||
410 | } |