| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| 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 |
||
| 25 | public function testCreateReturnResults() |
||
| 26 | { |
||
| 27 | $cardId = '1000'; |
||
| 28 | $name = 'name'; |
||
| 29 | $listBefore = 'listBefore'; |
||
| 30 | $listAfter = 'listAfter'; |
||
| 31 | $date = '2019-04-29 00:00:00'; |
||
| 32 | $name2 = 'name2'; |
||
| 33 | $listBefore2 = 'listBefore2'; |
||
| 34 | $listAfter2 = 'listAfter2'; |
||
| 35 | $date2 = '2019-04-29 10:00:00'; |
||
| 36 | |||
| 37 | $cards = [ |
||
| 38 | [ |
||
| 39 | 'id' => $cardId |
||
| 40 | ] |
||
| 41 | ]; |
||
| 42 | |||
| 43 | $data = [ |
||
| 44 | [ |
||
| 45 | 'id' => $cardId, |
||
| 46 | 'data' => [ |
||
| 47 | 'card' => [ |
||
| 48 | 'id' => $cardId, |
||
| 49 | 'name' => $name, |
||
| 50 | ], |
||
| 51 | 'listBefore' => [ |
||
| 52 | 'name' => $listBefore, |
||
| 53 | ], |
||
| 54 | 'listAfter' => [ |
||
| 55 | 'name' => $listAfter, |
||
| 56 | ] |
||
| 57 | ], |
||
| 58 | 'date' => $date |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | 'id' => $cardId, |
||
| 62 | 'data' => [ |
||
| 63 | 'card' => [ |
||
| 64 | 'id' => $cardId, |
||
| 65 | 'name' => $name2, |
||
| 66 | ], |
||
| 67 | 'listBefore' => [ |
||
| 68 | 'name' => $listBefore2, |
||
| 69 | ], |
||
| 70 | 'listAfter' => [ |
||
| 71 | 'name' => $listAfter2, |
||
| 72 | ] |
||
| 73 | ], |
||
| 74 | 'date' => $date2 |
||
| 75 | ] |
||
| 76 | ]; |
||
| 77 | |||
| 78 | $this->client->findCreationCard($cardId)->willReturn([]); |
||
| 79 | $this->client->findAllCardHistory($cardId)->willReturn($data); |
||
| 80 | $cardHistoryCollection = HistoryCards::createFromCards($this->client->reveal(), $cards); |
||
| 81 | |||
| 82 | $cardHistory = HistoryCard::createFromArray([ |
||
| 83 | 'id' => $cardId, |
||
| 84 | 'data' => [ |
||
| 85 | 'card' => [ |
||
| 86 | 'id' => $cardId, |
||
| 87 | 'name' => $name, |
||
| 88 | ], |
||
| 89 | 'listBefore' => [ |
||
| 90 | 'name' => $listBefore, |
||
| 91 | ], |
||
| 92 | 'listAfter' => [ |
||
| 93 | 'name' => $listAfter, |
||
| 94 | ] |
||
| 95 | ], |
||
| 96 | 'date' => $date |
||
| 97 | ]); |
||
| 98 | |||
| 99 | $cardHistory2 = HistoryCard::createFromArray([ |
||
| 100 | 'id' => $cardId, |
||
| 101 | 'data' => [ |
||
| 102 | 'card' => [ |
||
| 103 | 'id' => $cardId, |
||
| 104 | 'name' => $name2, |
||
| 105 | ], |
||
| 106 | 'listBefore' => [ |
||
| 107 | 'name' => $listBefore2, |
||
| 108 | ], |
||
| 109 | 'listAfter' => [ |
||
| 110 | 'name' => $listAfter2, |
||
| 111 | ] |
||
| 112 | ], |
||
| 113 | 'date' => $date2 |
||
| 114 | ]); |
||
| 115 | |||
| 116 | $expected = [$cardHistory, $cardHistory2]; |
||
| 117 | $histories = $cardHistoryCollection->getCardHistories(); |
||
| 118 | $this->assertEquals($expected, $histories); |
||
| 119 | } |
||
| 120 | } |
||
| 121 |