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