| Conditions | 1 |
| Paths | 1 |
| Total Lines | 120 |
| Code Lines | 87 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 1 | Features | 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 |
||
| 87 | public function testDataTables(): void |
||
| 88 | { |
||
| 89 | $this->get('/reports/data_tables?sEcho=1&iDisplayLength=25'); |
||
| 90 | $expected = [ |
||
| 91 | 'iTotalRecords' => 4, |
||
| 92 | 'iTotalDisplayRecords' => 4, |
||
| 93 | 'sEcho' => 1, |
||
| 94 | 'aaData' => [ |
||
| 95 | [ |
||
| 96 | '<input type="checkbox" name="reports[]" value="1"/>', |
||
| 97 | 1, |
||
| 98 | 'error2', |
||
| 99 | 'Lorem ipsum dolor sit amet', |
||
| 100 | 'filename_1.php', |
||
| 101 | '4.0', |
||
| 102 | 'Forwarded', |
||
| 103 | 'js', |
||
| 104 | '1', |
||
| 105 | ], |
||
| 106 | [ |
||
| 107 | '<input type="checkbox" name="reports[]" value="2"/>', |
||
| 108 | 2, |
||
| 109 | 'error2', |
||
| 110 | 'Lorem ipsum dolor sit amet', |
||
| 111 | 'filename_2.php', |
||
| 112 | '4.0', |
||
| 113 | 'Forwarded', |
||
| 114 | 'js', |
||
| 115 | '1', |
||
| 116 | ], |
||
| 117 | [ |
||
| 118 | '<input type="checkbox" name="reports[]" value="4"/>', |
||
| 119 | 4, |
||
| 120 | 'error1', |
||
| 121 | 'Lorem ipsum dolor sit amet', |
||
| 122 | 'filename_3.js', |
||
| 123 | '3.8', |
||
| 124 | 'Forwarded', |
||
| 125 | 'js', |
||
| 126 | '2', |
||
| 127 | ], |
||
| 128 | [ |
||
| 129 | '<input type="checkbox" name="reports[]" value="5"/>', |
||
| 130 | 5, |
||
| 131 | 'error1', |
||
| 132 | 'Lorem ipsum dolor sit amet', |
||
| 133 | 'filename_4.js', |
||
| 134 | '3.8', |
||
| 135 | 'New', |
||
| 136 | 'js', |
||
| 137 | '1', |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ]; |
||
| 141 | $this->assertEquals($expected, json_decode($this->_response->getBody(), true)); |
||
| 142 | |||
| 143 | $this->get('/reports/data_tables?sEcho=1&sSearch=error2&bSearchable_2=true&iSortCol_0=0&sSortDir_0=desc&bSortable_0=true&iSortingCols=2&iDisplayLength=25'); |
||
| 144 | $expected = [ |
||
| 145 | 'iTotalRecords' => 4, |
||
| 146 | 'iTotalDisplayRecords' => 2, |
||
| 147 | 'sEcho' => 1, |
||
| 148 | 'aaData' => [ |
||
| 149 | [ |
||
| 150 | '<input type="checkbox" name="reports[]" value="1"/>', |
||
| 151 | 1, |
||
| 152 | 'error2', |
||
| 153 | 'Lorem ipsum dolor sit amet', |
||
| 154 | 'filename_1.php', |
||
| 155 | '4.0', |
||
| 156 | 'Forwarded', |
||
| 157 | 'js', |
||
| 158 | '1', |
||
| 159 | ], |
||
| 160 | [ |
||
| 161 | '<input type="checkbox" name="reports[]" value="2"/>', |
||
| 162 | 2, |
||
| 163 | 'error2', |
||
| 164 | 'Lorem ipsum dolor sit amet', |
||
| 165 | 'filename_2.php', |
||
| 166 | '4.0', |
||
| 167 | 'Forwarded', |
||
| 168 | 'js', |
||
| 169 | '1', |
||
| 170 | ], |
||
| 171 | ], |
||
| 172 | ]; |
||
| 173 | $result = json_decode($this->_response->getBody(), true); |
||
| 174 | $this->assertEquals($expected, $result); |
||
| 175 | |||
| 176 | $this->get('/reports/data_tables?sEcho=1&sSearch_1=1&iDisplayLength=25'); |
||
| 177 | $expected = [ |
||
| 178 | 'iTotalRecords' => 4, |
||
| 179 | 'iTotalDisplayRecords' => 1, |
||
| 180 | 'sEcho' => 1, |
||
| 181 | 'aaData' => [ |
||
| 182 | [ |
||
| 183 | '<input type="checkbox" name="reports[]" value="1"/>', |
||
| 184 | 1, |
||
| 185 | 'error2', |
||
| 186 | 'Lorem ipsum dolor sit amet', |
||
| 187 | 'filename_1.php', |
||
| 188 | '4.0', |
||
| 189 | 'Forwarded', |
||
| 190 | 'js', |
||
| 191 | '1', |
||
| 192 | ], |
||
| 193 | ], |
||
| 194 | ]; |
||
| 195 | $result = json_decode($this->_response->getBody(), true); |
||
| 196 | $this->assertEquals($expected, $result); |
||
| 197 | |||
| 198 | $this->get('/reports/data_tables?sEcho=1&sSearch_1=0&iDisplayLength=25'); |
||
| 199 | $expected = [ |
||
| 200 | 'iTotalRecords' => 4, |
||
| 201 | 'iTotalDisplayRecords' => 0, |
||
| 202 | 'sEcho' => 1, |
||
| 203 | 'aaData' => [], |
||
| 204 | ]; |
||
| 205 | $result = json_decode($this->_response->getBody(), true); |
||
| 206 | $this->assertEquals($expected, $result); |
||
| 207 | } |
||
| 351 |