Conditions | 1 |
Paths | 1 |
Total Lines | 88 |
Code Lines | 75 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
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 |
||
170 | public function testSearchItems() |
||
171 | { |
||
172 | $item = $this->object->findItem( '[email protected]', ['text'] ); |
||
173 | $listItem = $item->getListItems( 'text', 'default' )->first( new \RuntimeException( 'No list item found' ) ); |
||
174 | |||
175 | $search = $this->object->createSearch(); |
||
176 | |||
177 | $expr = []; |
||
178 | $expr[] = $search->compare( '!=', 'customer.id', null ); |
||
179 | $expr[] = $search->compare( '==', 'customer.label', '[email protected]' ); |
||
180 | $expr[] = $search->compare( '==', 'customer.code', '[email protected]' ); |
||
181 | $expr[] = $search->compare( '>=', 'customer.password', '' ); |
||
182 | $expr[] = $search->compare( '==', 'customer.status', 1 ); |
||
183 | $expr[] = $search->compare( '>', 'customer.mtime', '1970-01-01 00:00:00' ); |
||
184 | $expr[] = $search->compare( '>', 'customer.ctime', '1970-01-01 00:00:00' ); |
||
185 | $expr[] = $search->compare( '==', 'customer.editor', $this->editor ); |
||
186 | |||
187 | $expr[] = $search->compare( '==', 'customer.salutation', 'mr' ); |
||
188 | $expr[] = $search->compare( '==', 'customer.company', 'Example company' ); |
||
189 | $expr[] = $search->compare( '==', 'customer.vatid', 'DE999999999' ); |
||
190 | $expr[] = $search->compare( '==', 'customer.title', 'Dr' ); |
||
191 | $expr[] = $search->compare( '==', 'customer.firstname', 'Our' ); |
||
192 | $expr[] = $search->compare( '==', 'customer.lastname', 'Unittest' ); |
||
193 | $expr[] = $search->compare( '==', 'customer.address1', 'Pickhuben' ); |
||
194 | $expr[] = $search->compare( '==', 'customer.address2', '2-4' ); |
||
195 | $expr[] = $search->compare( '==', 'customer.address3', '' ); |
||
196 | $expr[] = $search->compare( '==', 'customer.postal', '20457' ); |
||
197 | $expr[] = $search->compare( '==', 'customer.city', 'Hamburg' ); |
||
198 | $expr[] = $search->compare( '==', 'customer.state', 'Hamburg' ); |
||
199 | $expr[] = $search->compare( '==', 'customer.languageid', 'de' ); |
||
200 | $expr[] = $search->compare( '==', 'customer.countryid', 'DE' ); |
||
201 | $expr[] = $search->compare( '==', 'customer.telephone', '055544332211' ); |
||
202 | $expr[] = $search->compare( '==', 'customer.email', '[email protected]' ); |
||
203 | $expr[] = $search->compare( '==', 'customer.telefax', '055544332212' ); |
||
204 | $expr[] = $search->compare( '==', 'customer.website', 'www.example.com' ); |
||
205 | $expr[] = $search->compare( '==', 'customer.longitude', '10.0' ); |
||
206 | $expr[] = $search->compare( '==', 'customer.latitude', '50.0' ); |
||
207 | $expr[] = $search->compare( '==', 'customer.birthday', '1999-01-01' ); |
||
208 | |||
209 | $param = ['text', 'default', $listItem->getRefId()]; |
||
210 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:has', $param ), null ); |
||
211 | |||
212 | $param = ['text', 'default']; |
||
213 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:has', $param ), null ); |
||
214 | |||
215 | $param = ['text']; |
||
216 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:has', $param ), null ); |
||
217 | |||
218 | $param = ['newsletter', null, '1']; |
||
219 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:prop', $param ), null ); |
||
220 | |||
221 | $param = ['newsletter', null]; |
||
222 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:prop', $param ), null ); |
||
223 | |||
224 | $param = ['newsletter']; |
||
225 | $expr[] = $search->compare( '!=', $search->createFunction( 'customer:prop', $param ), null ); |
||
226 | |||
227 | $expr[] = $search->compare( '!=', 'customer.address.id', null ); |
||
228 | $expr[] = $search->compare( '!=', 'customer.address.parentid', null ); |
||
229 | $expr[] = $search->compare( '==', 'customer.address.salutation', 'mr' ); |
||
230 | $expr[] = $search->compare( '==', 'customer.address.company', 'Example company' ); |
||
231 | $expr[] = $search->compare( '==', 'customer.address.vatid', 'DE999999999' ); |
||
232 | $expr[] = $search->compare( '==', 'customer.address.title', 'Dr' ); |
||
233 | $expr[] = $search->compare( '==', 'customer.address.firstname', 'Our' ); |
||
234 | $expr[] = $search->compare( '==', 'customer.address.lastname', 'Unittest' ); |
||
235 | $expr[] = $search->compare( '==', 'customer.address.address1', 'Pickhuben' ); |
||
236 | $expr[] = $search->compare( '==', 'customer.address.address2', '2-4' ); |
||
237 | $expr[] = $search->compare( '==', 'customer.address.address3', '' ); |
||
238 | $expr[] = $search->compare( '==', 'customer.address.postal', '20457' ); |
||
239 | $expr[] = $search->compare( '==', 'customer.address.city', 'Hamburg' ); |
||
240 | $expr[] = $search->compare( '==', 'customer.address.state', 'Hamburg' ); |
||
241 | $expr[] = $search->compare( '==', 'customer.address.languageid', 'de' ); |
||
242 | $expr[] = $search->compare( '==', 'customer.address.countryid', 'DE' ); |
||
243 | $expr[] = $search->compare( '==', 'customer.address.telephone', '055544332211' ); |
||
244 | $expr[] = $search->compare( '==', 'customer.address.email', '[email protected]' ); |
||
245 | $expr[] = $search->compare( '==', 'customer.address.telefax', '055544332212' ); |
||
246 | $expr[] = $search->compare( '==', 'customer.address.website', 'www.example.com' ); |
||
247 | $expr[] = $search->compare( '==', 'customer.address.longitude', '10.0' ); |
||
248 | $expr[] = $search->compare( '==', 'customer.address.latitude', '50.0' ); |
||
249 | $expr[] = $search->compare( '==', 'customer.address.position', 0 ); |
||
250 | $expr[] = $search->compare( '==', 'customer.address.birthday', '2000-01-01' ); |
||
251 | $expr[] = $search->compare( '>=', 'customer.address.mtime', '1970-01-01 00:00:00' ); |
||
252 | $expr[] = $search->compare( '>=', 'customer.address.ctime', '1970-01-01 00:00:00' ); |
||
253 | $expr[] = $search->compare( '==', 'customer.address.editor', $this->editor ); |
||
254 | |||
255 | $search->setConditions( $search->combine( '&&', $expr ) ); |
||
256 | $result = $this->object->searchItems( $search ); |
||
257 | $this->assertEquals( 1, count( $result ) ); |
||
258 | } |
||
321 |