Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like SearchServiceTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SearchServiceTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
32 | class SearchServiceTest extends BaseTest |
||
33 | { |
||
34 | const QUERY_CLASS = Query::class; |
||
35 | |||
36 | use Common\FacetedSearchProvider; |
||
37 | |||
38 | public function getFilterContentSearches() |
||
39 | { |
||
40 | $fixtureDir = $this->getFixtureDir(); |
||
41 | |||
42 | return [ |
||
43 | 0 => [ |
||
44 | [ |
||
45 | 'filter' => new Criterion\ContentId( |
||
46 | [1, 4, 10] |
||
47 | ), |
||
48 | 'sortClauses' => [new SortClause\ContentId()], |
||
49 | ], |
||
50 | $fixtureDir . 'ContentId.php', |
||
51 | ], |
||
52 | 1 => [ |
||
53 | [ |
||
54 | 'filter' => new Criterion\LogicalAnd( |
||
55 | [ |
||
56 | new Criterion\ContentId( |
||
57 | [1, 4, 10] |
||
58 | ), |
||
59 | new Criterion\ContentId( |
||
60 | [4, 12] |
||
61 | ), |
||
62 | ] |
||
63 | ), |
||
64 | 'sortClauses' => [new SortClause\ContentId()], |
||
65 | ], |
||
66 | $fixtureDir . 'LogicalAnd.php', |
||
67 | ], |
||
68 | 2 => [ |
||
69 | [ |
||
70 | 'filter' => new Criterion\LogicalOr( |
||
71 | [ |
||
72 | new Criterion\ContentId( |
||
73 | [1, 4, 10] |
||
74 | ), |
||
75 | new Criterion\ContentId( |
||
76 | [4, 12] |
||
77 | ), |
||
78 | ] |
||
79 | ), |
||
80 | 'sortClauses' => [new SortClause\ContentId()], |
||
81 | ], |
||
82 | $fixtureDir . 'LogicalOr.php', |
||
83 | ], |
||
84 | 3 => [ |
||
85 | [ |
||
86 | 'filter' => new Criterion\LogicalAnd( |
||
87 | [ |
||
88 | new Criterion\ContentId( |
||
89 | [1, 4, 10] |
||
90 | ), |
||
91 | new Criterion\LogicalNot( |
||
92 | new Criterion\ContentId( |
||
93 | [10, 12] |
||
94 | ) |
||
95 | ), |
||
96 | ] |
||
97 | ), |
||
98 | 'sortClauses' => [new SortClause\ContentId()], |
||
99 | ], |
||
100 | $fixtureDir . 'LogicalNot.php', |
||
101 | ], |
||
102 | 4 => [ |
||
103 | [ |
||
104 | 'filter' => new Criterion\LogicalAnd( |
||
105 | [ |
||
106 | new Criterion\ContentId( |
||
107 | [1, 4, 10] |
||
108 | ), |
||
109 | new Criterion\LogicalAnd( |
||
110 | [ |
||
111 | new Criterion\LogicalNot( |
||
112 | new Criterion\ContentId( |
||
113 | [10, 12] |
||
114 | ) |
||
115 | ), |
||
116 | ] |
||
117 | ), |
||
118 | ] |
||
119 | ), |
||
120 | 'sortClauses' => [new SortClause\ContentId()], |
||
121 | ], |
||
122 | $fixtureDir . 'LogicalNot.php', |
||
123 | ], |
||
124 | 5 => [ |
||
125 | [ |
||
126 | 'filter' => new Criterion\ContentTypeId( |
||
127 | 4 |
||
128 | ), |
||
129 | 'sortClauses' => [new SortClause\ContentId()], |
||
130 | ], |
||
131 | $fixtureDir . 'ContentTypeId.php', |
||
132 | ], |
||
133 | 6 => [ |
||
134 | [ |
||
135 | 'filter' => new Criterion\ContentTypeIdentifier( |
||
136 | 'user' |
||
137 | ), |
||
138 | 'sortClauses' => [new SortClause\ContentId()], |
||
139 | ], |
||
140 | $fixtureDir . 'ContentTypeId.php', |
||
141 | ], |
||
142 | 7 => [ |
||
143 | [ |
||
144 | 'filter' => new Criterion\MatchNone(), |
||
145 | 'sortClauses' => [new SortClause\ContentId()], |
||
146 | ], |
||
147 | $fixtureDir . 'MatchNone.php', |
||
148 | ], |
||
149 | 8 => [ |
||
150 | [ |
||
151 | 'filter' => new Criterion\ContentTypeGroupId( |
||
152 | 2 |
||
153 | ), |
||
154 | 'sortClauses' => [new SortClause\ContentId()], |
||
155 | ], |
||
156 | $fixtureDir . 'ContentTypeGroupId.php', |
||
157 | ], |
||
158 | 9 => [ |
||
159 | [ |
||
160 | 'filter' => new Criterion\DateMetadata( |
||
161 | Criterion\DateMetadata::MODIFIED, |
||
162 | Criterion\Operator::GT, |
||
163 | 1343140540 |
||
164 | ), |
||
165 | 'sortClauses' => [new SortClause\ContentId()], |
||
166 | ], |
||
167 | $fixtureDir . 'DateMetadataGt.php', |
||
168 | ], |
||
169 | 10 => [ |
||
170 | [ |
||
171 | 'filter' => new Criterion\DateMetadata( |
||
172 | Criterion\DateMetadata::MODIFIED, |
||
173 | Criterion\Operator::GTE, |
||
174 | 1311154215 |
||
175 | ), |
||
176 | 'sortClauses' => [new SortClause\ContentId()], |
||
177 | ], |
||
178 | $fixtureDir . 'DateMetadataGte.php', |
||
179 | ], |
||
180 | 11 => [ |
||
181 | [ |
||
182 | 'filter' => new Criterion\DateMetadata( |
||
183 | Criterion\DateMetadata::MODIFIED, |
||
184 | Criterion\Operator::LTE, |
||
185 | 1311154215 |
||
186 | ), |
||
187 | 'limit' => 10, |
||
188 | 'sortClauses' => [new SortClause\ContentId()], |
||
189 | ], |
||
190 | $fixtureDir . 'DateMetadataLte.php', |
||
191 | ], |
||
192 | 12 => [ |
||
193 | [ |
||
194 | 'filter' => new Criterion\DateMetadata( |
||
195 | Criterion\DateMetadata::MODIFIED, |
||
196 | Criterion\Operator::IN, |
||
197 | [1033920794, 1060695457, 1343140540] |
||
198 | ), |
||
199 | 'sortClauses' => [new SortClause\ContentId()], |
||
200 | ], |
||
201 | $fixtureDir . 'DateMetadataIn.php', |
||
202 | ], |
||
203 | 13 => [ |
||
204 | [ |
||
205 | 'filter' => new Criterion\DateMetadata( |
||
206 | Criterion\DateMetadata::MODIFIED, |
||
207 | Criterion\Operator::BETWEEN, |
||
208 | [1033920776, 1072180276] |
||
209 | ), |
||
210 | 'sortClauses' => [new SortClause\ContentId()], |
||
211 | ], |
||
212 | $fixtureDir . 'DateMetadataBetween.php', |
||
213 | ], |
||
214 | 14 => [ |
||
215 | [ |
||
216 | 'filter' => new Criterion\DateMetadata( |
||
217 | Criterion\DateMetadata::CREATED, |
||
218 | Criterion\Operator::BETWEEN, |
||
219 | [1033920776, 1072180278] |
||
220 | ), |
||
221 | 'sortClauses' => [new SortClause\ContentId()], |
||
222 | ], |
||
223 | $fixtureDir . 'DateMetadataCreated.php', |
||
224 | ], |
||
225 | 15 => [ |
||
226 | [ |
||
227 | 'filter' => new Criterion\CustomField( |
||
228 | 'user_group_name_value_s', |
||
229 | Criterion\Operator::EQ, |
||
230 | 'Members' |
||
231 | ), |
||
232 | 'sortClauses' => [new SortClause\ContentId()], |
||
233 | ], |
||
234 | $fixtureDir . 'Field.php', |
||
235 | ], |
||
236 | 16 => [ |
||
237 | [ |
||
238 | 'filter' => new Criterion\CustomField( |
||
239 | 'user_group_name_value_s', |
||
240 | Criterion\Operator::CONTAINS, |
||
241 | 'Members' |
||
242 | ), |
||
243 | 'sortClauses' => [new SortClause\ContentId()], |
||
244 | ], |
||
245 | $fixtureDir . 'Field.php', |
||
246 | ], |
||
247 | 17 => [ |
||
248 | [ |
||
249 | 'filter' => new Criterion\CustomField( |
||
250 | 'user_group_name_value_s', |
||
251 | Criterion\Operator::LT, |
||
252 | 'Members' |
||
253 | ), |
||
254 | 'sortClauses' => [new SortClause\ContentId()], |
||
255 | ], |
||
256 | $fixtureDir . 'CustomFieldLt.php', |
||
257 | ], |
||
258 | 18 => [ |
||
259 | [ |
||
260 | 'filter' => new Criterion\CustomField( |
||
261 | 'user_group_name_value_s', |
||
262 | Criterion\Operator::LTE, |
||
263 | 'Members' |
||
264 | ), |
||
265 | 'sortClauses' => [new SortClause\ContentId()], |
||
266 | ], |
||
267 | $fixtureDir . 'CustomFieldLte.php', |
||
268 | ], |
||
269 | 19 => [ |
||
270 | [ |
||
271 | 'filter' => new Criterion\CustomField( |
||
272 | 'user_group_name_value_s', |
||
273 | Criterion\Operator::GT, |
||
274 | 'Members' |
||
275 | ), |
||
276 | 'sortClauses' => [new SortClause\ContentId()], |
||
277 | ], |
||
278 | $fixtureDir . 'CustomFieldGt.php', |
||
279 | ], |
||
280 | 20 => [ |
||
281 | [ |
||
282 | 'filter' => new Criterion\CustomField( |
||
283 | 'user_group_name_value_s', |
||
284 | Criterion\Operator::GTE, |
||
285 | 'Members' |
||
286 | ), |
||
287 | 'sortClauses' => [new SortClause\ContentId()], |
||
288 | ], |
||
289 | $fixtureDir . 'CustomFieldGte.php', |
||
290 | ], |
||
291 | 21 => [ |
||
292 | [ |
||
293 | 'filter' => new Criterion\CustomField( |
||
294 | 'user_group_name_value_s', |
||
295 | Criterion\Operator::BETWEEN, |
||
296 | ['Administrator users', 'Members'] |
||
297 | ), |
||
298 | 'sortClauses' => [new SortClause\ContentId()], |
||
299 | ], |
||
300 | $fixtureDir . 'CustomFieldBetween.php', |
||
301 | ], |
||
302 | 22 => [ |
||
303 | [ |
||
304 | 'filter' => new Criterion\RemoteId( |
||
305 | ['f5c88a2209584891056f987fd965b0ba', 'faaeb9be3bd98ed09f606fc16d144eca'] |
||
306 | ), |
||
307 | 'sortClauses' => [new SortClause\ContentId()], |
||
308 | ], |
||
309 | $fixtureDir . 'RemoteId.php', |
||
310 | ], |
||
311 | 23 => [ |
||
312 | [ |
||
313 | 'filter' => new Criterion\SectionId( |
||
314 | [2] |
||
315 | ), |
||
316 | 'sortClauses' => [new SortClause\ContentId()], |
||
317 | ], |
||
318 | $fixtureDir . 'SectionId.php', |
||
319 | ], |
||
320 | 24 => [ |
||
321 | [ |
||
322 | 'filter' => new Criterion\Field( |
||
323 | 'name', |
||
324 | Criterion\Operator::EQ, |
||
325 | 'Members' |
||
326 | ), |
||
327 | 'sortClauses' => [new SortClause\ContentId()], |
||
328 | ], |
||
329 | $fixtureDir . 'Field.php', |
||
330 | ], |
||
331 | 25 => [ |
||
332 | [ |
||
333 | 'filter' => new Criterion\Field( |
||
334 | 'name', |
||
335 | Criterion\Operator::IN, |
||
336 | ['Members', 'Anonymous Users'] |
||
337 | ), |
||
338 | 'sortClauses' => [new SortClause\ContentId()], |
||
339 | ], |
||
340 | $fixtureDir . 'FieldIn.php', |
||
341 | ], |
||
342 | 26 => [ |
||
343 | [ |
||
344 | 'filter' => new Criterion\DateMetadata( |
||
345 | Criterion\DateMetadata::MODIFIED, |
||
346 | Criterion\Operator::BETWEEN, |
||
347 | [1033920275, 1033920794] |
||
348 | ), |
||
349 | 'sortClauses' => [new SortClause\ContentId()], |
||
350 | ], |
||
351 | $fixtureDir . 'FieldBetween.php', |
||
352 | ], |
||
353 | 27 => [ |
||
354 | [ |
||
355 | 'filter' => new Criterion\LogicalOr( |
||
356 | [ |
||
357 | new Criterion\Field( |
||
358 | 'name', |
||
359 | Criterion\Operator::EQ, |
||
360 | 'Members' |
||
361 | ), |
||
362 | new Criterion\DateMetadata( |
||
363 | Criterion\DateMetadata::MODIFIED, |
||
364 | Criterion\Operator::BETWEEN, |
||
365 | [1033920275, 1033920794] |
||
366 | ), |
||
367 | ] |
||
368 | ), |
||
369 | 'sortClauses' => [new SortClause\ContentId()], |
||
370 | ], |
||
371 | $fixtureDir . 'FieldOr.php', |
||
372 | ], |
||
373 | 28 => [ |
||
374 | [ |
||
375 | 'filter' => new Criterion\Subtree( |
||
376 | '/1/5/' |
||
377 | ), |
||
378 | 'sortClauses' => [new SortClause\ContentId()], |
||
379 | ], |
||
380 | $fixtureDir . 'Subtree.php', |
||
381 | ], |
||
382 | 29 => [ |
||
383 | [ |
||
384 | 'filter' => new Criterion\LocationId( |
||
385 | [1, 2, 5] |
||
386 | ), |
||
387 | 'sortClauses' => [new SortClause\ContentId()], |
||
388 | ], |
||
389 | $fixtureDir . 'LocationId.php', |
||
390 | ], |
||
391 | 30 => [ |
||
392 | [ |
||
393 | 'filter' => new Criterion\ParentLocationId( |
||
394 | [1] |
||
395 | ), |
||
396 | 'sortClauses' => [new SortClause\ContentId()], |
||
397 | ], |
||
398 | $fixtureDir . 'ParentLocationId.php', |
||
399 | ], |
||
400 | 31 => [ |
||
401 | [ |
||
402 | 'filter' => new Criterion\LocationRemoteId( |
||
403 | ['3f6d92f8044aed134f32153517850f5a', 'f3e90596361e31d496d4026eb624c983'] |
||
404 | ), |
||
405 | 'sortClauses' => [new SortClause\ContentId()], |
||
406 | ], |
||
407 | $fixtureDir . 'LocationRemoteId.php', |
||
408 | ], |
||
409 | 32 => [ |
||
410 | [ |
||
411 | // There is no Status Criterion anymore, this should match all published as well |
||
412 | 'filter' => new Criterion\Subtree( |
||
413 | '/1/' |
||
414 | ), |
||
415 | 'sortClauses' => [new SortClause\ContentId()], |
||
416 | 'limit' => 50, |
||
417 | ], |
||
418 | $fixtureDir . 'Status.php', |
||
419 | // Result having the same sort level should be sorted between them to be system independent |
||
420 | function (&$data) { |
||
421 | usort( |
||
422 | $data->searchHits, |
||
423 | function ($a, $b) { |
||
424 | if ($a->score == $b->score) { |
||
425 | if ($a->valueObject['id'] == $b->valueObject['id']) { |
||
426 | return 0; |
||
427 | } |
||
428 | |||
429 | // Order by ascending ID |
||
430 | return ($a->valueObject['id'] < $b->valueObject['id']) ? -1 : 1; |
||
431 | } |
||
432 | |||
433 | // Order by descending score |
||
434 | return ($a->score > $b->score) ? -1 : 1; |
||
435 | } |
||
436 | ); |
||
437 | }, |
||
438 | ], |
||
439 | 33 => [ |
||
440 | [ |
||
441 | 'filter' => new Criterion\UserMetadata( |
||
442 | Criterion\UserMetadata::MODIFIER, |
||
443 | Criterion\Operator::EQ, |
||
444 | 14 |
||
445 | ), |
||
446 | 'sortClauses' => [ |
||
447 | new SortClause\ContentId(), |
||
448 | ], |
||
449 | 'limit' => 50, |
||
450 | ], |
||
451 | $fixtureDir . 'UserMetadata.php', |
||
452 | ], |
||
453 | 34 => [ |
||
454 | [ |
||
455 | 'filter' => new Criterion\UserMetadata( |
||
456 | Criterion\UserMetadata::MODIFIER, |
||
457 | Criterion\Operator::IN, |
||
458 | [14] |
||
459 | ), |
||
460 | 'sortClauses' => [ |
||
461 | new SortClause\ContentId(), |
||
462 | ], |
||
463 | 'limit' => 50, |
||
464 | ], |
||
465 | $fixtureDir . 'UserMetadata.php', |
||
466 | ], |
||
467 | 35 => [ |
||
468 | [ |
||
469 | 'filter' => new Criterion\UserMetadata( |
||
470 | Criterion\UserMetadata::OWNER, |
||
471 | Criterion\Operator::EQ, |
||
472 | 14 |
||
473 | ), |
||
474 | 'sortClauses' => [ |
||
475 | new SortClause\ContentId(), |
||
476 | ], |
||
477 | 'limit' => 50, |
||
478 | ], |
||
479 | $fixtureDir . 'UserMetadata.php', |
||
480 | ], |
||
481 | 36 => [ |
||
482 | [ |
||
483 | 'filter' => new Criterion\UserMetadata( |
||
484 | Criterion\UserMetadata::OWNER, |
||
485 | Criterion\Operator::IN, |
||
486 | [14] |
||
487 | ), |
||
488 | 'sortClauses' => [ |
||
489 | new SortClause\ContentId(), |
||
490 | ], |
||
491 | 'limit' => 50, |
||
492 | ], |
||
493 | $fixtureDir . 'UserMetadata.php', |
||
494 | ], |
||
495 | 37 => [ |
||
496 | [ |
||
497 | 'filter' => new Criterion\UserMetadata( |
||
498 | Criterion\UserMetadata::GROUP, |
||
499 | Criterion\Operator::EQ, |
||
500 | 12 |
||
501 | ), |
||
502 | 'sortClauses' => [ |
||
503 | new SortClause\ContentId(), |
||
504 | ], |
||
505 | 'limit' => 50, |
||
506 | ], |
||
507 | $fixtureDir . 'UserMetadata.php', |
||
508 | ], |
||
509 | 38 => [ |
||
510 | [ |
||
511 | 'filter' => new Criterion\UserMetadata( |
||
512 | Criterion\UserMetadata::GROUP, |
||
513 | Criterion\Operator::IN, |
||
514 | [12] |
||
515 | ), |
||
516 | 'sortClauses' => [ |
||
517 | new SortClause\ContentId(), |
||
518 | ], |
||
519 | 'limit' => 50, |
||
520 | ], |
||
521 | $fixtureDir . 'UserMetadata.php', |
||
522 | ], |
||
523 | 39 => [ |
||
524 | [ |
||
525 | 'filter' => new Criterion\UserMetadata( |
||
526 | Criterion\UserMetadata::GROUP, |
||
527 | Criterion\Operator::EQ, |
||
528 | 4 |
||
529 | ), |
||
530 | 'sortClauses' => [ |
||
531 | new SortClause\ContentId(), |
||
532 | ], |
||
533 | 'limit' => 50, |
||
534 | ], |
||
535 | $fixtureDir . 'UserMetadata.php', |
||
536 | ], |
||
537 | 40 => [ |
||
538 | [ |
||
539 | 'filter' => new Criterion\UserMetadata( |
||
540 | Criterion\UserMetadata::GROUP, |
||
541 | Criterion\Operator::IN, |
||
542 | [4] |
||
543 | ), |
||
544 | 'sortClauses' => [ |
||
545 | new SortClause\ContentId(), |
||
546 | ], |
||
547 | 'limit' => 50, |
||
548 | ], |
||
549 | $fixtureDir . 'UserMetadata.php', |
||
550 | ], |
||
551 | 41 => [ |
||
552 | [ |
||
553 | 'filter' => new Criterion\Ancestor( |
||
554 | [ |
||
555 | '/1/5/44/', |
||
556 | '/1/5/44/45/', |
||
557 | ] |
||
558 | ), |
||
559 | 'sortClauses' => [ |
||
560 | new SortClause\ContentId(), |
||
561 | ], |
||
562 | 'limit' => 50, |
||
563 | ], |
||
564 | $fixtureDir . 'AncestorContent.php', |
||
565 | ], |
||
566 | ]; |
||
567 | } |
||
568 | |||
569 | public function getContentQuerySearches() |
||
570 | { |
||
571 | $fixtureDir = $this->getFixtureDir(); |
||
572 | |||
573 | return [ |
||
574 | [ |
||
575 | [ |
||
576 | 'filter' => new Criterion\ContentId( |
||
577 | [58, 10] |
||
578 | ), |
||
579 | 'query' => new Criterion\FullText('contact'), |
||
580 | 'sortClauses' => [new SortClause\ContentId()], |
||
581 | ], |
||
582 | $fixtureDir . 'FullTextFiltered.php', |
||
583 | ], |
||
584 | [ |
||
585 | [ |
||
586 | 'query' => new Criterion\FullText( |
||
587 | 'contact', |
||
588 | [ |
||
589 | 'boost' => [ |
||
590 | 'title' => 2, |
||
591 | ], |
||
592 | 'fuzziness' => .5, |
||
593 | ] |
||
594 | ), |
||
595 | 'sortClauses' => [new SortClause\ContentId()], |
||
596 | ], |
||
597 | $fixtureDir . 'FullText.php', |
||
598 | ], |
||
599 | [ |
||
600 | [ |
||
601 | 'query' => new Criterion\FullText( |
||
602 | 'Contact*' |
||
603 | ), |
||
604 | 'sortClauses' => [new SortClause\ContentId()], |
||
605 | ], |
||
606 | $fixtureDir . 'FullTextWildcard.php', |
||
607 | ], |
||
608 | [ |
||
609 | [ |
||
610 | 'query' => new Criterion\LanguageCode('eng-GB', false), |
||
611 | 'sortClauses' => [new SortClause\ContentId()], |
||
612 | ], |
||
613 | $fixtureDir . 'LanguageCode.php', |
||
614 | ], |
||
615 | [ |
||
616 | [ |
||
617 | 'query' => new Criterion\LanguageCode(['eng-US', 'eng-GB']), |
||
618 | 'offset' => 10, |
||
619 | 'sortClauses' => [new SortClause\ContentId()], |
||
620 | ], |
||
621 | $fixtureDir . 'LanguageCodeIn.php', |
||
622 | ], |
||
623 | [ |
||
624 | [ |
||
625 | 'query' => new Criterion\LanguageCode('eng-GB'), |
||
626 | 'offset' => 10, |
||
627 | 'sortClauses' => [new SortClause\ContentId()], |
||
628 | ], |
||
629 | $fixtureDir . 'LanguageCodeAlwaysAvailable.php', |
||
630 | ], |
||
631 | [ |
||
632 | [ |
||
633 | 'query' => new Criterion\Visibility( |
||
634 | Criterion\Visibility::VISIBLE |
||
635 | ), |
||
636 | 'sortClauses' => [new SortClause\ContentId()], |
||
637 | 'limit' => 50, |
||
638 | ], |
||
639 | $fixtureDir . 'Visibility.php', |
||
640 | ], |
||
641 | ]; |
||
642 | } |
||
643 | |||
644 | public function getLocationQuerySearches() |
||
645 | { |
||
646 | $fixtureDir = $this->getFixtureDir(); |
||
647 | |||
648 | return [ |
||
649 | [ |
||
650 | [ |
||
651 | 'query' => new Criterion\Location\Depth(Criterion\Operator::EQ, 1), |
||
652 | 'sortClauses' => [new SortClause\ContentId()], |
||
653 | ], |
||
654 | $fixtureDir . 'Depth.php', |
||
655 | ], |
||
656 | [ |
||
657 | [ |
||
658 | 'query' => new Criterion\Location\Depth(Criterion\Operator::IN, [1, 3]), |
||
659 | 'sortClauses' => [new SortClause\ContentId()], |
||
660 | ], |
||
661 | $fixtureDir . 'DepthIn.php', |
||
662 | ], |
||
663 | [ |
||
664 | [ |
||
665 | 'query' => new Criterion\Location\Depth(Criterion\Operator::GT, 2), |
||
666 | 'sortClauses' => [new SortClause\ContentId()], |
||
667 | ], |
||
668 | $fixtureDir . 'DepthGt.php', |
||
669 | ], |
||
670 | [ |
||
671 | [ |
||
672 | 'query' => new Criterion\Location\Depth(Criterion\Operator::GTE, 2), |
||
673 | 'sortClauses' => [new SortClause\ContentId()], |
||
674 | 'limit' => 50, |
||
675 | ], |
||
676 | $fixtureDir . 'DepthGte.php', |
||
677 | ], |
||
678 | [ |
||
679 | [ |
||
680 | 'query' => new Criterion\Location\Depth(Criterion\Operator::LT, 2), |
||
681 | 'sortClauses' => [new SortClause\ContentId()], |
||
682 | ], |
||
683 | $fixtureDir . 'Depth.php', |
||
684 | ], |
||
685 | [ |
||
686 | [ |
||
687 | 'query' => new Criterion\Location\Depth(Criterion\Operator::LTE, 2), |
||
688 | 'sortClauses' => [new SortClause\ContentId()], |
||
689 | 'limit' => 50, |
||
690 | ], |
||
691 | $fixtureDir . 'DepthLte.php', |
||
692 | ], |
||
693 | [ |
||
694 | [ |
||
695 | 'query' => new Criterion\Location\Depth(Criterion\Operator::BETWEEN, [1, 2]), |
||
696 | 'sortClauses' => [new SortClause\ContentId()], |
||
697 | 'limit' => 50, |
||
698 | ], |
||
699 | $fixtureDir . 'DepthLte.php', |
||
700 | ], |
||
701 | [ |
||
702 | [ |
||
703 | 'filter' => new Criterion\Ancestor('/1/5/44/45/'), |
||
704 | 'sortClauses' => [ |
||
705 | new SortClause\Location\Depth(), |
||
706 | ], |
||
707 | 'limit' => 50, |
||
708 | ], |
||
709 | $fixtureDir . 'AncestorLocation.php', |
||
710 | ], |
||
711 | ]; |
||
712 | } |
||
713 | |||
714 | /** |
||
715 | * Test for the findContent() method. |
||
716 | * |
||
717 | * @dataProvider getFilterContentSearches |
||
718 | * |
||
719 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
720 | */ |
||
721 | public function testFindContentFiltered($queryData, $fixture, $closure = null) |
||
722 | { |
||
723 | $query = new Query($queryData); |
||
724 | $this->assertQueryFixture($query, $fixture, $closure); |
||
725 | } |
||
726 | |||
727 | /** |
||
728 | * Test for the findContentInfo() method. |
||
729 | * |
||
730 | * @dataProvider getFilterContentSearches |
||
731 | * @see \eZ\Publish\API\Repository\SearchService::findContentInfo() |
||
732 | */ |
||
733 | public function testFindContentInfoFiltered($queryData, $fixture, $closure = null) |
||
734 | { |
||
735 | $query = new Query($queryData); |
||
736 | $this->assertQueryFixture($query, $fixture, $this->getContentInfoFixtureClosure($closure), true); |
||
737 | } |
||
738 | |||
739 | /** |
||
740 | * Test for the findLocations() method. |
||
741 | * |
||
742 | * @dataProvider getFilterContentSearches |
||
743 | * |
||
744 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
745 | */ |
||
746 | public function testFindLocationsContentFiltered($queryData, $fixture, $closure = null) |
||
747 | { |
||
748 | $query = new LocationQuery($queryData); |
||
749 | $this->assertQueryFixture($query, $fixture, $closure); |
||
750 | } |
||
751 | |||
752 | /** |
||
753 | * Test for deprecated $criterion property on query object. |
||
754 | * |
||
755 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
756 | * @deprecated |
||
757 | */ |
||
758 | public function testDeprecatedCriteriaProperty() |
||
759 | { |
||
760 | $this->assertQueryFixture( |
||
761 | new Query( |
||
762 | [ |
||
763 | 'query' => new Criterion\ContentId( |
||
764 | [1, 4, 10] |
||
765 | ), |
||
766 | 'sortClauses' => [new SortClause\ContentId()], |
||
767 | ] |
||
768 | ), |
||
769 | $this->getFixtureDir() . 'DeprecatedContentIdQuery.php' |
||
770 | ); |
||
771 | } |
||
772 | |||
773 | /** |
||
774 | * Test for the findContent() method. |
||
775 | * |
||
776 | * @dataProvider getContentQuerySearches |
||
777 | * |
||
778 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
779 | */ |
||
780 | public function testQueryContent($queryData, $fixture, $closure = null) |
||
781 | { |
||
782 | $query = new Query($queryData); |
||
783 | $this->assertQueryFixture($query, $fixture, $closure); |
||
784 | } |
||
785 | |||
786 | /** |
||
787 | * Test for the findContentInfo() method. |
||
788 | * |
||
789 | * @dataProvider getContentQuerySearches |
||
790 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
791 | */ |
||
792 | public function testQueryContentInfo($queryData, $fixture, $closure = null) |
||
793 | { |
||
794 | $query = new Query($queryData); |
||
795 | $this->assertQueryFixture($query, $fixture, $this->getContentInfoFixtureClosure($closure), true); |
||
796 | } |
||
797 | |||
798 | /** |
||
799 | * Test for the findLocations() method. |
||
800 | * |
||
801 | * @dataProvider getContentQuerySearches |
||
802 | * |
||
803 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
804 | */ |
||
805 | public function testQueryContentLocations($queryData, $fixture, $closure = null) |
||
806 | { |
||
807 | $query = new LocationQuery($queryData); |
||
808 | $this->assertQueryFixture($query, $fixture, $closure); |
||
809 | } |
||
810 | |||
811 | /** |
||
812 | * Test for the findLocations() method. |
||
813 | * |
||
814 | * @dataProvider getLocationQuerySearches |
||
815 | * |
||
816 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
817 | */ |
||
818 | public function testQueryLocations($queryData, $fixture, $closure = null) |
||
819 | { |
||
820 | $query = new LocationQuery($queryData); |
||
821 | $this->assertQueryFixture($query, $fixture, $closure); |
||
822 | } |
||
823 | |||
824 | public function getCaseInsensitiveSearches() |
||
825 | { |
||
826 | return [ |
||
827 | [ |
||
828 | [ |
||
829 | 'filter' => new Criterion\Field( |
||
830 | 'name', |
||
831 | Criterion\Operator::EQ, |
||
832 | 'Members' |
||
833 | ), |
||
834 | 'sortClauses' => [new SortClause\ContentId()], |
||
835 | ], |
||
836 | ], |
||
837 | [ |
||
838 | [ |
||
839 | 'filter' => new Criterion\Field( |
||
840 | 'name', |
||
841 | Criterion\Operator::EQ, |
||
842 | 'members' |
||
843 | ), |
||
844 | 'sortClauses' => [new SortClause\ContentId()], |
||
845 | ], |
||
846 | ], |
||
847 | [ |
||
848 | [ |
||
849 | 'filter' => new Criterion\Field( |
||
850 | 'name', |
||
851 | Criterion\Operator::EQ, |
||
852 | 'MEMBERS' |
||
853 | ), |
||
854 | 'sortClauses' => [new SortClause\ContentId()], |
||
855 | ], |
||
856 | ], |
||
857 | ]; |
||
858 | } |
||
859 | |||
860 | /** |
||
861 | * Test for the findContent() method. |
||
862 | * |
||
863 | * @dataProvider getCaseInsensitiveSearches |
||
864 | * |
||
865 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
866 | */ |
||
867 | public function testFindContentFieldFiltersCaseSensitivity($queryData) |
||
868 | { |
||
869 | $query = new Query($queryData); |
||
870 | $this->assertQueryFixture( |
||
871 | $query, |
||
872 | $this->getFixtureDir() . 'Field.php' |
||
873 | ); |
||
874 | } |
||
875 | |||
876 | /** |
||
877 | * Test for the findLocations() method. |
||
878 | * |
||
879 | * @dataProvider getCaseInsensitiveSearches |
||
880 | * |
||
881 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
882 | */ |
||
883 | public function testFindLocationsFieldFiltersCaseSensitivity($queryData) |
||
884 | { |
||
885 | $query = new LocationQuery($queryData); |
||
886 | $this->assertQueryFixture( |
||
887 | $query, |
||
888 | $this->getFixtureDir() . 'Field.php' |
||
889 | ); |
||
890 | } |
||
891 | |||
892 | public function getRelationFieldFilterSearches() |
||
893 | { |
||
894 | $fixtureDir = $this->getFixtureDir(); |
||
895 | |||
896 | return [ |
||
897 | 0 => [ |
||
898 | [ |
||
899 | 'filter' => new Criterion\FieldRelation( |
||
900 | 'image', |
||
901 | Criterion\Operator::IN, |
||
902 | [1, 4, 10] |
||
903 | ), |
||
904 | 'sortClauses' => [new SortClause\ContentId()], |
||
905 | ], |
||
906 | $fixtureDir . 'FieldRelation.php', |
||
907 | ], |
||
908 | 1 => [ |
||
909 | [ |
||
910 | 'filter' => new Criterion\FieldRelation( |
||
911 | 'image', |
||
912 | Criterion\Operator::IN, |
||
913 | [4, 49] |
||
914 | ), |
||
915 | 'sortClauses' => [new SortClause\ContentId()], |
||
916 | ], |
||
917 | $fixtureDir . 'FieldRelationAll.php', |
||
918 | ], |
||
919 | 2 => [ |
||
920 | [ |
||
921 | 'filter' => new Criterion\FieldRelation( |
||
922 | 'image', |
||
923 | Criterion\Operator::IN, |
||
924 | [4] |
||
925 | ), |
||
926 | 'sortClauses' => [new SortClause\ContentId()], |
||
927 | ], |
||
928 | $fixtureDir . 'FieldRelation.php', |
||
929 | ], |
||
930 | 3 => [ |
||
931 | [ |
||
932 | 'filter' => new Criterion\FieldRelation( |
||
933 | 'image', |
||
934 | Criterion\Operator::CONTAINS, |
||
935 | [1, 4, 10] |
||
936 | ), |
||
937 | 'sortClauses' => [new SortClause\ContentId()], |
||
938 | ], |
||
939 | $fixtureDir . 'MatchNone.php', |
||
940 | ], |
||
941 | 4 => [ |
||
942 | [ |
||
943 | 'filter' => new Criterion\FieldRelation( |
||
944 | 'image', |
||
945 | Criterion\Operator::CONTAINS, |
||
946 | [4, 49] |
||
947 | ), |
||
948 | 'sortClauses' => [new SortClause\ContentId()], |
||
949 | ], |
||
950 | $fixtureDir . 'MatchNone.php', |
||
951 | ], |
||
952 | 5 => [ |
||
953 | [ |
||
954 | 'filter' => new Criterion\FieldRelation( |
||
955 | 'image', |
||
956 | Criterion\Operator::CONTAINS, |
||
957 | [4] |
||
958 | ), |
||
959 | 'sortClauses' => [new SortClause\ContentId()], |
||
960 | ], |
||
961 | $fixtureDir . 'FieldRelation.php', |
||
962 | ], |
||
963 | ]; |
||
964 | } |
||
965 | |||
966 | /** |
||
967 | * Purely for creating relation data needed for testFindRelationFieldContentInfoFiltered() |
||
968 | * and testFindRelationFieldLocationsFiltered(). |
||
969 | */ |
||
970 | public function testRelationContentCreation() |
||
971 | { |
||
972 | $repository = $this->getRepository(); |
||
973 | $galleryType = $repository->getContentTypeService()->loadContentTypeByIdentifier('gallery'); |
||
974 | $contentService = $repository->getContentService(); |
||
975 | $locationService = $repository->getLocationService(); |
||
976 | |||
977 | $locationCreateStruct = $locationService->newLocationCreateStruct(2); // Home |
||
978 | |||
979 | $createStruct = $contentService->newContentCreateStruct($galleryType, 'eng-GB'); |
||
980 | $createStruct->setField('name', 'Image gallery'); |
||
981 | $createStruct->setField('image', 49); // Images folder |
||
982 | $draft = $contentService->createContent($createStruct, [$locationCreateStruct]); |
||
983 | $contentService->publishVersion($draft->getVersionInfo()); |
||
984 | |||
985 | $createStruct = $contentService->newContentCreateStruct($galleryType, 'eng-GB'); |
||
986 | $createStruct->setField('name', 'User gallery'); |
||
987 | $createStruct->setField('image', 4); // User folder |
||
988 | $draft = $contentService->createContent($createStruct, [$locationCreateStruct]); |
||
989 | $contentService->publishVersion($draft->getVersionInfo()); |
||
990 | |||
991 | $this->refreshSearch($repository); |
||
992 | } |
||
993 | |||
994 | /** |
||
995 | * Test for FieldRelation using findContentInfo() method. |
||
996 | * |
||
997 | * @dataProvider getRelationFieldFilterSearches |
||
998 | * @see \eZ\Publish\API\Repository\SearchService::findContentInfo() |
||
999 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testRelationContentCreation |
||
1000 | */ |
||
1001 | public function testFindRelationFieldContentInfoFiltered($queryData, $fixture) |
||
1002 | { |
||
1003 | $this->getRepository(false); // To make sure repo is setup w/o removing data from getRelationFieldFilterContentSearches |
||
1004 | $query = new Query($queryData); |
||
1005 | $this->assertQueryFixture($query, $fixture, null, true, true, false); |
||
1006 | } |
||
1007 | |||
1008 | /** |
||
1009 | * Test for FieldRelation using findLocations() method. |
||
1010 | * |
||
1011 | * @dataProvider getRelationFieldFilterSearches |
||
1012 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
1013 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testRelationContentCreation |
||
1014 | */ |
||
1015 | public function testFindRelationFieldLocationsFiltered($queryData, $fixture) |
||
1016 | { |
||
1017 | $this->getRepository(false); // To make sure repo is setup w/o removing data from getRelationFieldFilterContentSearches |
||
1018 | $query = new LocationQuery($queryData); |
||
1019 | $this->assertQueryFixture($query, $fixture, null, true, false, false); |
||
1020 | } |
||
1021 | |||
1022 | View Code Duplication | public function testFindSingle() |
|
1023 | { |
||
1024 | $repository = $this->getRepository(); |
||
1025 | $searchService = $repository->getSearchService(); |
||
1026 | |||
1027 | $content = $searchService->findSingle( |
||
1028 | new Criterion\ContentId( |
||
1029 | [4] |
||
1030 | ) |
||
1031 | ); |
||
1032 | |||
1033 | $this->assertEquals( |
||
1034 | 4, |
||
1035 | $content->id |
||
1036 | ); |
||
1037 | } |
||
1038 | |||
1039 | View Code Duplication | public function testFindNoPerformCount() |
|
1040 | { |
||
1041 | $repository = $this->getRepository(); |
||
1042 | $searchService = $repository->getSearchService(); |
||
1043 | |||
1044 | $query = new Query(); |
||
1045 | $query->performCount = false; |
||
1046 | $query->query = new Criterion\ContentTypeId( |
||
1047 | [4] |
||
1048 | ); |
||
1049 | |||
1050 | $searchHit = $searchService->findContent($query); |
||
1051 | |||
1052 | if (ltrim(get_class($this->getSetupFactory()), '\\') === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy') { |
||
1053 | $this->assertNull( |
||
1054 | $searchHit->totalCount |
||
1055 | ); |
||
1056 | } else { |
||
1057 | $this->assertEquals( |
||
1058 | 2, |
||
1059 | $searchHit->totalCount |
||
1060 | ); |
||
1061 | } |
||
1062 | } |
||
1063 | |||
1064 | /** |
||
1065 | * @expectedException \RuntimeException |
||
1066 | */ |
||
1067 | View Code Duplication | public function testFindNoPerformCountException() |
|
1085 | |||
1086 | View Code Duplication | public function testFindLocationsNoPerformCount() |
|
1087 | { |
||
1088 | $repository = $this->getRepository(); |
||
1089 | $searchService = $repository->getSearchService(); |
||
1090 | |||
1091 | $query = new LocationQuery(); |
||
1092 | $query->performCount = false; |
||
1093 | $query->query = new Criterion\ContentTypeId( |
||
1094 | [4] |
||
1095 | ); |
||
1096 | |||
1097 | $searchHit = $searchService->findLocations($query); |
||
1098 | |||
1099 | if (ltrim(get_class($this->getSetupFactory()), '\\') === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy') { |
||
1100 | $this->assertNull( |
||
1101 | $searchHit->totalCount |
||
1102 | ); |
||
1103 | } else { |
||
1104 | $this->assertEquals( |
||
1105 | 2, |
||
1106 | $searchHit->totalCount |
||
1107 | ); |
||
1108 | } |
||
1109 | } |
||
1110 | |||
1111 | /** |
||
1112 | * @expectedException \RuntimeException |
||
1113 | */ |
||
1114 | View Code Duplication | public function testFindLocationsNoPerformCountException() |
|
1115 | { |
||
1116 | if (ltrim(get_class($this->getSetupFactory()), '\\') !== 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy') { |
||
1117 | $this->markTestSkipped('Only applicable to Legacy/DB based search'); |
||
1118 | } |
||
1119 | |||
1120 | $repository = $this->getRepository(); |
||
1121 | $searchService = $repository->getSearchService(); |
||
1122 | |||
1123 | $query = new LocationQuery(); |
||
1124 | $query->performCount = false; |
||
1125 | $query->limit = 0; |
||
1126 | $query->query = new Criterion\ContentTypeId( |
||
1127 | [4] |
||
1128 | ); |
||
1129 | |||
1130 | $searchService->findLocations($query); |
||
1131 | } |
||
1132 | |||
1133 | /** |
||
1134 | * Create test Content with ezcountry field having multiple countries selected. |
||
1135 | * |
||
1136 | * @return Content |
||
1137 | */ |
||
1138 | protected function createMultipleCountriesContent() |
||
1181 | |||
1182 | /** |
||
1183 | * Test for the findContent() method. |
||
1184 | * |
||
1185 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
1186 | */ |
||
1187 | View Code Duplication | public function testFieldCollectionContains() |
|
1211 | |||
1212 | /** |
||
1213 | * Test for the findContent() method. |
||
1214 | * |
||
1215 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
1216 | * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains |
||
1217 | */ |
||
1218 | View Code Duplication | public function testFieldCollectionContainsNoMatch() |
|
1237 | |||
1238 | /** |
||
1239 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1240 | * @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'some_hopefully_unknown_field' |
||
1241 | */ |
||
1242 | View Code Duplication | public function testInvalidFieldIdentifierRange() |
|
1243 | { |
||
1244 | $repository = $this->getRepository(); |
||
1245 | $searchService = $repository->getSearchService(); |
||
1246 | |||
1247 | $searchService->findContent( |
||
1248 | new Query( |
||
1249 | [ |
||
1250 | 'filter' => new Criterion\Field( |
||
1251 | 'some_hopefully_unknown_field', |
||
1252 | Criterion\Operator::BETWEEN, |
||
1253 | [10, 1000] |
||
1254 | ), |
||
1255 | 'sortClauses' => [new SortClause\ContentId()], |
||
1256 | ] |
||
1257 | ) |
||
1258 | ); |
||
1259 | } |
||
1260 | |||
1261 | /** |
||
1262 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1263 | * @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'some_hopefully_unknown_field' |
||
1264 | */ |
||
1265 | View Code Duplication | public function testInvalidFieldIdentifierIn() |
|
1283 | |||
1284 | /** |
||
1285 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1286 | * @expectedExceptionMessage Argument '$criterion->target' is invalid: No searchable fields found for the given criterion target 'tag_cloud_url' |
||
1287 | */ |
||
1288 | View Code Duplication | public function testFindContentWithNonSearchableField() |
|
1306 | |||
1307 | /** |
||
1308 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1309 | * @expectedExceptionMessage Argument '$sortClause->targetData' is invalid: No searchable fields found for the given sort clause target 'title' on 'template_look' |
||
1310 | */ |
||
1311 | View Code Duplication | public function testSortFieldWithNonSearchableField() |
|
1324 | |||
1325 | /** |
||
1326 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1327 | * @expectedExceptionMessage Argument '$sortClause->targetData' is invalid: No searchable fields found for the given sort clause target 'title' on 'template_look' |
||
1328 | */ |
||
1329 | View Code Duplication | public function testSortMapLocationDistanceWithNonSearchableField() |
|
1349 | |||
1350 | /** |
||
1351 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1352 | */ |
||
1353 | View Code Duplication | public function testFindSingleFailMultiple() |
|
1364 | |||
1365 | /** |
||
1366 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1367 | */ |
||
1368 | public function testFindSingleWithNonSearchableField() |
||
1381 | |||
1382 | public function getSortedContentSearches() |
||
1529 | |||
1530 | public function getSortedLocationSearches() |
||
1602 | |||
1603 | /** |
||
1604 | * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType |
||
1605 | */ |
||
1606 | View Code Duplication | protected function createTestContentType() |
|
1642 | |||
1643 | /** |
||
1644 | * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType |
||
1645 | * @param int $fieldValue11 Value for translatable field in first language |
||
1646 | * @param int $fieldValue12 Value for translatable field in second language |
||
1647 | * @param int $fieldValue2 Value for non translatable field |
||
1648 | * @param string $mainLanguageCode |
||
1649 | * @param bool $alwaysAvailable |
||
1650 | * |
||
1651 | * @return Content |
||
1652 | */ |
||
1653 | protected function createMultilingualContent( |
||
1683 | |||
1684 | protected function checkPrioritizedLanguagesSupport() |
||
1691 | |||
1692 | public function providerForTestMultilingualFieldSort() |
||
1997 | |||
1998 | /** |
||
1999 | * Test for the findContent() method. |
||
2000 | * |
||
2001 | * @group rrr |
||
2002 | * @dataProvider providerForTestMultilingualFieldSort |
||
2003 | * |
||
2004 | * @param array $contentDataList |
||
2005 | * @param array $languageSettings |
||
2006 | * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses |
||
2007 | * @param array $expected |
||
2008 | */ |
||
2009 | public function testMultilingualFieldSortContent( |
||
2022 | |||
2023 | /** |
||
2024 | * Test for the findLocations() method. |
||
2025 | * |
||
2026 | * @group rrr |
||
2027 | * @dataProvider providerForTestMultilingualFieldSort |
||
2028 | * |
||
2029 | * @param array $contentDataList |
||
2030 | * @param array $languageSettings |
||
2031 | * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses |
||
2032 | * @param array $expected |
||
2033 | */ |
||
2034 | public function testMultilingualFieldSortLocation( |
||
2048 | |||
2049 | /** |
||
2050 | * @param array $contentDataList |
||
2051 | * @param array $languageSettings |
||
2052 | * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses |
||
2053 | * @param array $expected |
||
2054 | * @param bool $contentSearch |
||
2055 | */ |
||
2056 | protected function assertMultilingualFieldSort( |
||
2127 | |||
2128 | public function providerForTestMultilingualFieldFilter() |
||
2286 | |||
2287 | /** |
||
2288 | * Test for the findContent() method. |
||
2289 | * |
||
2290 | * @group ttt |
||
2291 | * @dataProvider providerForTestMultilingualFieldFilter |
||
2292 | * |
||
2293 | * @param array $contentDataList |
||
2294 | * @param array $languageSettings |
||
2295 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
||
2296 | * @param array $expected |
||
2297 | */ |
||
2298 | public function testMultilingualFieldFilterContent( |
||
2311 | |||
2312 | /** |
||
2313 | * Test for the findLocations() method. |
||
2314 | * |
||
2315 | * @group ttt |
||
2316 | * @dataProvider providerForTestMultilingualFieldFilter |
||
2317 | * |
||
2318 | * @param array $contentDataList |
||
2319 | * @param array $languageSettings |
||
2320 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
||
2321 | * @param array $expected |
||
2322 | */ |
||
2323 | public function testMultilingualFieldFilterLocation( |
||
2337 | |||
2338 | /** |
||
2339 | * @param array $contentDataList |
||
2340 | * @param array $languageSettings |
||
2341 | * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion |
||
2342 | * @param array $expected |
||
2343 | * @param bool $contentSearch |
||
2344 | */ |
||
2345 | protected function assertMultilingualFieldFilter( |
||
2421 | |||
2422 | /** |
||
2423 | * @param \eZ\Publish\API\Repository\Values\Content\Search\SearchResult $result |
||
2424 | * |
||
2425 | * @return array |
||
2426 | */ |
||
2427 | protected function mapResultContentIds(SearchResult $result) |
||
2440 | |||
2441 | /** |
||
2442 | * Test for the findContent() method. |
||
2443 | * |
||
2444 | * @dataProvider getSortedContentSearches |
||
2445 | * |
||
2446 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2447 | */ |
||
2448 | public function testFindAndSortContent($queryData, $fixture, $closure = null) |
||
2453 | |||
2454 | /** |
||
2455 | * Test for the findContentInfo() method. |
||
2456 | * |
||
2457 | * @dataProvider getSortedContentSearches |
||
2458 | * @see \eZ\Publish\API\Repository\SearchService::findContentInfo() |
||
2459 | */ |
||
2460 | public function testFindAndSortContentInfo($queryData, $fixture, $closure = null) |
||
2465 | |||
2466 | /** |
||
2467 | * Test for the findLocations() method. |
||
2468 | * |
||
2469 | * @dataProvider getSortedContentSearches |
||
2470 | * |
||
2471 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
2472 | */ |
||
2473 | public function testFindAndSortContentLocations($queryData, $fixture, $closure = null) |
||
2478 | |||
2479 | /** |
||
2480 | * Test for the findLocations() method. |
||
2481 | * |
||
2482 | * @dataProvider getSortedLocationSearches |
||
2483 | * |
||
2484 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
2485 | */ |
||
2486 | public function testFindAndSortLocations($queryData, $fixture, $closure = null) |
||
2491 | |||
2492 | /** |
||
2493 | * Test for the findContent() method. |
||
2494 | * |
||
2495 | * @dataProvider getFacetedSearches |
||
2496 | * |
||
2497 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2498 | */ |
||
2499 | public function testFindFacetedContent(Query $query, $fixture) |
||
2503 | |||
2504 | /** |
||
2505 | * Test for the findContentInfo() method. |
||
2506 | * |
||
2507 | * @dataProvider getFacetedSearches |
||
2508 | * @see \eZ\Publish\API\Repository\SearchService::findContentInfo() |
||
2509 | */ |
||
2510 | public function testFindFacetedContentInfo(Query $query, $fixture) |
||
2514 | |||
2515 | /** |
||
2516 | * Test for the findContent() method. |
||
2517 | * |
||
2518 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2519 | */ |
||
2520 | View Code Duplication | public function testQueryCustomField() |
|
2539 | |||
2540 | /** |
||
2541 | * Test for the findContent() method. |
||
2542 | * |
||
2543 | * This tests explicitely queries the first_name while user is contained in |
||
2544 | * the last_name of admin and anonymous. This is done to show the custom |
||
2545 | * copy field working. |
||
2546 | * |
||
2547 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2548 | */ |
||
2549 | View Code Duplication | public function testQueryModifiedField() |
|
2578 | |||
2579 | /** |
||
2580 | * Test for the findContent() method. |
||
2581 | * |
||
2582 | * This tests first explicitly creates sort clause on the 'short_name' which is empty |
||
2583 | * for all Content instances of 'folder' ContentType. Custom sort field is then set |
||
2584 | * to the index storage name of folder's 'name' field, in order to show the custom |
||
2585 | * sort field working. |
||
2586 | * |
||
2587 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2588 | */ |
||
2589 | public function testSortModifiedField() |
||
2619 | |||
2620 | /** |
||
2621 | * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType |
||
2622 | */ |
||
2623 | View Code Duplication | protected function createTestPlaceContentType() |
|
2650 | |||
2651 | /** |
||
2652 | * Test for the findContent() method. |
||
2653 | * |
||
2654 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2655 | * @group maplocation |
||
2656 | */ |
||
2657 | View Code Duplication | public function testMapLocationDistanceLessThanOrEqual() |
|
2730 | |||
2731 | /** |
||
2732 | * Test for the findContent() method. |
||
2733 | * |
||
2734 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2735 | * @group maplocation |
||
2736 | */ |
||
2737 | View Code Duplication | public function testMapLocationDistanceGreaterThanOrEqual() |
|
2810 | |||
2811 | /** |
||
2812 | * Test for the findContent() method. |
||
2813 | * |
||
2814 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2815 | * @group maplocation |
||
2816 | */ |
||
2817 | public function testMapLocationDistanceBetween() |
||
2906 | |||
2907 | /** |
||
2908 | * Test for the findContent() method. |
||
2909 | * |
||
2910 | * This tests the distance over the pole. The tests intentionally uses large range, |
||
2911 | * as the flat Earth model used in Legacy Storage Search is not precise for the use case. |
||
2912 | * What is tested here is that outer bounding box is correctly calculated, so that |
||
2913 | * location is not excluded. |
||
2914 | * |
||
2915 | * Range between 222km and 350km shows the magnitude of error between great-circle |
||
2916 | * (always very precise) and flat Earth (very imprecise for this use case) models. |
||
2917 | * |
||
2918 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2919 | * @group maplocation |
||
2920 | */ |
||
2921 | public function testMapLocationDistanceBetweenPolar() |
||
2978 | |||
2979 | /** |
||
2980 | * Test for the findContent() method. |
||
2981 | * |
||
2982 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
2983 | * @group maplocation |
||
2984 | */ |
||
2985 | View Code Duplication | public function testMapLocationDistanceSortAscending() |
|
3095 | |||
3096 | /** |
||
3097 | * Test for the findContent() method. |
||
3098 | * |
||
3099 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3100 | * @group maplocation |
||
3101 | */ |
||
3102 | View Code Duplication | public function testMapLocationDistanceSortDescending() |
|
3212 | |||
3213 | /** |
||
3214 | * Test for the findContent() method. |
||
3215 | * |
||
3216 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3217 | * @group maplocation |
||
3218 | */ |
||
3219 | public function testMapLocationDistanceWithCustomField() |
||
3300 | |||
3301 | /** |
||
3302 | * Test for the findContent() method. |
||
3303 | * |
||
3304 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3305 | * @group maplocation |
||
3306 | */ |
||
3307 | public function testMapLocationDistanceWithCustomFieldSort() |
||
3425 | |||
3426 | /** |
||
3427 | * Test for the findLocations() method. |
||
3428 | * |
||
3429 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3430 | */ |
||
3431 | View Code Duplication | public function testFindMainLocation() |
|
3470 | |||
3471 | /** |
||
3472 | * Test for the findLocations() method. |
||
3473 | * |
||
3474 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3475 | */ |
||
3476 | View Code Duplication | public function testFindNonMainLocation() |
|
3514 | |||
3515 | /** |
||
3516 | * Test for the findLocations() method. |
||
3517 | * |
||
3518 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3519 | */ |
||
3520 | View Code Duplication | public function testSortMainLocationAscending() |
|
3557 | |||
3558 | /** |
||
3559 | * Test for the findLocations() method. |
||
3560 | * |
||
3561 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3562 | */ |
||
3563 | View Code Duplication | public function testSortMainLocationDescending() |
|
3600 | |||
3601 | /** |
||
3602 | * Test for the findLocations() method. |
||
3603 | * |
||
3604 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3605 | */ |
||
3606 | public function testContentWithMultipleLocations() |
||
3651 | |||
3652 | protected function createContentForTestUserMetadataGroupHorizontal() |
||
3704 | |||
3705 | /** |
||
3706 | * Test for the findContent() method. |
||
3707 | * |
||
3708 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3709 | */ |
||
3710 | public function testUserMetadataGroupHorizontalFilterContent($queryType = null) |
||
3783 | |||
3784 | /** |
||
3785 | * Test for the findContent() method. |
||
3786 | * |
||
3787 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3788 | */ |
||
3789 | public function testUserMetadataGroupHorizontalQueryContent() |
||
3793 | |||
3794 | /** |
||
3795 | * Test for the findLocations() method. |
||
3796 | * |
||
3797 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3798 | */ |
||
3799 | public function testUserMetadataGroupHorizontalFilterLocation($queryType = null) |
||
3882 | |||
3883 | /** |
||
3884 | * Test for the findLocations() method. |
||
3885 | * |
||
3886 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
3887 | */ |
||
3888 | public function testUserMetadataGroupHorizontalQueryLocation() |
||
3892 | |||
3893 | /** |
||
3894 | * Test for FullText on the findContent() method. |
||
3895 | * |
||
3896 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3897 | */ |
||
3898 | public function testFullTextOnNewContent() |
||
3933 | |||
3934 | /** |
||
3935 | * Test for the findContent() method. |
||
3936 | * |
||
3937 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
3938 | */ |
||
3939 | public function testLanguageAnalysisSeparateContent() |
||
4000 | |||
4001 | /** |
||
4002 | * Test for the findContent() method. |
||
4003 | * |
||
4004 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
4005 | */ |
||
4006 | public function testLanguageAnalysisSameContent() |
||
4053 | |||
4054 | /** |
||
4055 | * Test for the findContent() method. |
||
4056 | * |
||
4057 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
4058 | */ |
||
4059 | public function testLanguageAnalysisSameContentNotFound() |
||
4107 | |||
4108 | /** |
||
4109 | * Test for the findContent() method searching for content filtered by languages. |
||
4110 | * |
||
4111 | * @covers \eZ\Publish\Core\Repository\SearchService::findContent |
||
4112 | */ |
||
4113 | public function testFindContentWithLanguageFilter() |
||
4145 | |||
4146 | /** |
||
4147 | * This test prepares data for other tests. |
||
4148 | * |
||
4149 | * @see testFulltextContentSearchComplex |
||
4150 | * @see testFulltextLocationSearchComplex |
||
4151 | * |
||
4152 | * @return array |
||
4153 | */ |
||
4154 | public function testFulltextComplex() |
||
4205 | |||
4206 | /** |
||
4207 | * Test for the findContent() method. |
||
4208 | * |
||
4209 | * @see \eZ\Publish\API\Repository\SearchService::findContent() |
||
4210 | * @depends testFulltextComplex |
||
4211 | * |
||
4212 | * @param array $data |
||
4213 | */ |
||
4214 | public function testFulltextContentSearchComplex(array $data) |
||
4255 | |||
4256 | /** |
||
4257 | * Test for the findLocations() method. |
||
4258 | * |
||
4259 | * @see \eZ\Publish\API\Repository\SearchService::findLocations() |
||
4260 | * @depends testFulltextComplex |
||
4261 | * |
||
4262 | * @param array $data |
||
4263 | */ |
||
4264 | public function testFulltextLocationSearchComplex(array $data) |
||
4316 | |||
4317 | /** |
||
4318 | * Assert that query result matches the given fixture. |
||
4319 | * |
||
4320 | * @param Query $query |
||
4321 | * @param string $fixtureFilePath |
||
4322 | * @param null|callable $closure |
||
4323 | * @param bool $ignoreScore |
||
4324 | * @param bool $info |
||
4325 | * @param bool $id |
||
4326 | * |
||
4327 | * @throws \ErrorException |
||
4328 | * @throws \ReflectionException |
||
4329 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
4330 | */ |
||
4331 | protected function assertQueryFixture( |
||
4427 | |||
4428 | /** |
||
4429 | * Show a simplified view of the search result for manual introspection. |
||
4430 | * |
||
4431 | * @param SearchResult $result |
||
4432 | * |
||
4433 | * @return string |
||
4434 | */ |
||
4435 | View Code Duplication | protected function printResult(SearchResult $result) |
|
4444 | |||
4445 | /** |
||
4446 | * Simplify search result. |
||
4447 | * |
||
4448 | * This leads to saner comparisons of results, since we do not get the full |
||
4449 | * content objects every time. |
||
4450 | * |
||
4451 | * @param SearchResult $result |
||
4452 | */ |
||
4453 | protected function simplifySearchResult(SearchResult $result) |
||
4479 | |||
4480 | /** |
||
4481 | * Get fixture directory. |
||
4482 | * |
||
4483 | * @return string |
||
4484 | */ |
||
4485 | protected function getFixtureDir() |
||
4489 | |||
4490 | /** |
||
4491 | * For findContentInfo tests, to reuse fixtures for findContent tests. |
||
4492 | * |
||
4493 | * @param null|callable $closure |
||
4494 | * |
||
4495 | * @return callable |
||
4496 | */ |
||
4497 | private function getContentInfoFixtureClosure($closure = null) |
||
4512 | |||
4513 | /** |
||
4514 | * @dataProvider providerForTestSortingByNumericFieldsWithValuesOfDifferentLength |
||
4515 | * |
||
4516 | * @param int[] $expectedOrderedIds |
||
4517 | * |
||
4518 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
4519 | */ |
||
4520 | public function testSortingByNumericFieldsWithValuesOfDifferentLength( |
||
4541 | |||
4542 | public function providerForTestSortingByNumericFieldsWithValuesOfDifferentLength() |
||
4607 | } |
||
4608 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.