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