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