1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the eZ Publish Kernel package. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\Core\Search\Legacy\Tests\Content; |
10
|
|
|
|
11
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Tests\Content\LanguageAwareTestCase; |
12
|
|
|
use eZ\Publish\Core\Persistence; |
13
|
|
|
use eZ\Publish\Core\Search\Legacy\Content; |
14
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter; |
15
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\SortClauseConverter; |
16
|
|
|
use eZ\Publish\SPI\Persistence\Content\Location as SPILocation; |
17
|
|
|
use eZ\Publish\API\Repository\Values\Content\LocationQuery; |
18
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\Criterion; |
19
|
|
|
use eZ\Publish\API\Repository\Values\Content\Query\SortClause; |
20
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Location\Gateway\CriterionHandler as LocationCriterionHandler; |
21
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler as CommonCriterionHandler; |
22
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Location\Gateway\SortClauseHandler as LocationSortClauseHandler; |
23
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\SortClauseHandler as CommonSortClauseHandler; |
24
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter; |
25
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\ConverterRegistry; |
26
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Type\Gateway\DoctrineDatabase as ContentTypeGateway; |
27
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Type\Mapper as ContentTypeMapper; |
28
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler as ContentTypeHandler; |
29
|
|
|
use eZ\Publish\Core\Search\Legacy\Content\Gateway as ContentGateway; |
30
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Mapper as ContentMapper; |
31
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Type\Update\Handler as ContentTypeUpdateHandler; |
32
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper as LocationMapper; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Location Search test case for ContentSearchHandler. |
36
|
|
|
*/ |
37
|
|
|
class HandlerLocationTest extends LanguageAwareTestCase |
38
|
|
|
{ |
39
|
|
|
protected static $setUp = false; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Only set up once for these read only tests on a large fixture. |
43
|
|
|
* |
44
|
|
|
* Skipping the reset-up, since setting up for these tests takes quite some |
45
|
|
|
* time, which is not required to spent, since we are only reading from the |
46
|
|
|
* database anyways. |
47
|
|
|
*/ |
48
|
|
View Code Duplication |
public function setUp() |
49
|
|
|
{ |
50
|
|
|
if (!self::$setUp) { |
51
|
|
|
parent::setUp(); |
52
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/../_fixtures/full_dump.php'); |
53
|
|
|
self::$setUp = $this->handler; |
|
|
|
|
54
|
|
|
} else { |
55
|
|
|
$this->handler = self::$setUp; |
|
|
|
|
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Assert that the elements are. |
61
|
|
|
*/ |
62
|
|
View Code Duplication |
protected function assertSearchResults($expectedIds, $searchResult) |
63
|
|
|
{ |
64
|
|
|
$ids = array_map( |
65
|
|
|
function ($hit) { |
66
|
|
|
return $hit->valueObject->id; |
67
|
|
|
}, |
68
|
|
|
$searchResult->searchHits |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
sort($ids); |
72
|
|
|
|
73
|
|
|
$this->assertEquals($expectedIds, $ids); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Returns the location search handler to test. |
78
|
|
|
* |
79
|
|
|
* This method returns a fully functional search handler to perform tests on. |
80
|
|
|
* |
81
|
|
|
* @param array $fullTextSearchConfiguration |
82
|
|
|
* |
83
|
|
|
* @return \eZ\Publish\Core\Search\Legacy\Content\Handler |
84
|
|
|
*/ |
85
|
|
|
protected function getContentSearchHandler(array $fullTextSearchConfiguration = []) |
86
|
|
|
{ |
87
|
|
|
$transformationProcessor = new Persistence\TransformationProcessor\DefinitionBased( |
88
|
|
|
new Persistence\TransformationProcessor\DefinitionBased\Parser(), |
89
|
|
|
new Persistence\TransformationProcessor\PcreCompiler( |
90
|
|
|
new Persistence\Utf8Converter() |
91
|
|
|
), |
92
|
|
|
glob(__DIR__ . '/../../../../Persistence/Tests/TransformationProcessor/_fixtures/transformations/*.tr') |
93
|
|
|
); |
94
|
|
|
$commaSeparatedCollectionValueHandler = new CommonCriterionHandler\FieldValue\Handler\Collection( |
95
|
|
|
$this->getDatabaseHandler(), |
96
|
|
|
$transformationProcessor, |
97
|
|
|
',' |
98
|
|
|
); |
99
|
|
|
$hyphenSeparatedCollectionValueHandler = new CommonCriterionHandler\FieldValue\Handler\Collection( |
100
|
|
|
$this->getDatabaseHandler(), |
101
|
|
|
$transformationProcessor, |
102
|
|
|
'-' |
103
|
|
|
); |
104
|
|
|
$simpleValueHandler = new CommonCriterionHandler\FieldValue\Handler\Simple( |
105
|
|
|
$this->getDatabaseHandler(), |
106
|
|
|
$transformationProcessor |
107
|
|
|
); |
108
|
|
|
$compositeValueHandler = new CommonCriterionHandler\FieldValue\Handler\Composite( |
109
|
|
|
$this->getDatabaseHandler(), |
110
|
|
|
$transformationProcessor |
111
|
|
|
); |
112
|
|
|
|
113
|
|
|
return new Content\Handler( |
114
|
|
|
$this->createMock(ContentGateway::class), |
115
|
|
|
new Content\Location\Gateway\DoctrineDatabase( |
116
|
|
|
$this->getDatabaseHandler(), |
117
|
|
|
new CriteriaConverter( |
118
|
|
|
[ |
119
|
|
|
new LocationCriterionHandler\LocationId($this->getDatabaseHandler()), |
120
|
|
|
new LocationCriterionHandler\ParentLocationId($this->getDatabaseHandler()), |
121
|
|
|
new LocationCriterionHandler\LocationRemoteId($this->getDatabaseHandler()), |
122
|
|
|
new LocationCriterionHandler\Subtree($this->getDatabaseHandler()), |
123
|
|
|
new LocationCriterionHandler\Visibility($this->getDatabaseHandler()), |
124
|
|
|
new LocationCriterionHandler\Location\Depth($this->getDatabaseHandler()), |
125
|
|
|
new LocationCriterionHandler\Location\Priority($this->getDatabaseHandler()), |
126
|
|
|
new LocationCriterionHandler\Location\IsMainLocation($this->getDatabaseHandler()), |
127
|
|
|
new CommonCriterionHandler\ContentId($this->getDatabaseHandler()), |
128
|
|
|
new CommonCriterionHandler\ContentTypeGroupId($this->getDatabaseHandler()), |
129
|
|
|
new CommonCriterionHandler\ContentTypeId($this->getDatabaseHandler()), |
130
|
|
|
new CommonCriterionHandler\ContentTypeIdentifier( |
131
|
|
|
$this->getDatabaseHandler(), |
132
|
|
|
$this->getContentTypeHandler() |
133
|
|
|
), |
134
|
|
|
new CommonCriterionHandler\DateMetadata($this->getDatabaseHandler()), |
135
|
|
|
new CommonCriterionHandler\Field( |
136
|
|
|
$this->getDatabaseHandler(), |
137
|
|
|
$this->getContentTypeHandler(), |
138
|
|
|
$this->getLanguageHandler(), |
139
|
|
|
$this->getConverterRegistry(), |
140
|
|
|
new CommonCriterionHandler\FieldValue\Converter( |
141
|
|
|
new CommonCriterionHandler\FieldValue\HandlerRegistry( |
142
|
|
|
[ |
143
|
|
|
'ezboolean' => $simpleValueHandler, |
144
|
|
|
'ezcountry' => $commaSeparatedCollectionValueHandler, |
145
|
|
|
'ezdate' => $simpleValueHandler, |
146
|
|
|
'ezdatetime' => $simpleValueHandler, |
147
|
|
|
'ezemail' => $simpleValueHandler, |
148
|
|
|
'ezinteger' => $simpleValueHandler, |
149
|
|
|
'ezobjectrelation' => $simpleValueHandler, |
150
|
|
|
'ezobjectrelationlist' => $commaSeparatedCollectionValueHandler, |
151
|
|
|
'ezselection' => $hyphenSeparatedCollectionValueHandler, |
152
|
|
|
'eztime' => $simpleValueHandler, |
153
|
|
|
] |
154
|
|
|
), |
155
|
|
|
$compositeValueHandler |
156
|
|
|
), |
157
|
|
|
$transformationProcessor |
158
|
|
|
), |
159
|
|
|
new CommonCriterionHandler\FullText( |
160
|
|
|
$this->getDatabaseHandler(), |
161
|
|
|
$transformationProcessor, |
162
|
|
|
$fullTextSearchConfiguration |
163
|
|
|
), |
164
|
|
|
new CommonCriterionHandler\LanguageCode( |
165
|
|
|
$this->getDatabaseHandler(), |
166
|
|
|
$this->getLanguageMaskGenerator() |
167
|
|
|
), |
168
|
|
|
new CommonCriterionHandler\LogicalAnd($this->getDatabaseHandler()), |
169
|
|
|
new CommonCriterionHandler\LogicalNot($this->getDatabaseHandler()), |
170
|
|
|
new CommonCriterionHandler\LogicalOr($this->getDatabaseHandler()), |
171
|
|
|
new CommonCriterionHandler\MapLocationDistance( |
172
|
|
|
$this->getDatabaseHandler(), |
173
|
|
|
$this->getContentTypeHandler(), |
174
|
|
|
$this->getLanguageHandler() |
175
|
|
|
), |
176
|
|
|
new CommonCriterionHandler\MatchAll($this->getDatabaseHandler()), |
177
|
|
|
new CommonCriterionHandler\ObjectStateId($this->getDatabaseHandler()), |
178
|
|
|
new CommonCriterionHandler\FieldRelation( |
179
|
|
|
$this->getDatabaseHandler(), |
180
|
|
|
$this->getContentTypeHandler(), |
181
|
|
|
$this->getLanguageHandler() |
182
|
|
|
), |
183
|
|
|
new CommonCriterionHandler\RemoteId($this->getDatabaseHandler()), |
184
|
|
|
new CommonCriterionHandler\SectionId($this->getDatabaseHandler()), |
185
|
|
|
new CommonCriterionHandler\UserMetadata($this->getDatabaseHandler()), |
186
|
|
|
] |
187
|
|
|
), |
188
|
|
|
new SortClauseConverter( |
189
|
|
|
[ |
190
|
|
|
new LocationSortClauseHandler\Location\Id($this->getDatabaseHandler()), |
191
|
|
|
new CommonSortClauseHandler\ContentId($this->getDatabaseHandler()), |
192
|
|
|
] |
193
|
|
|
), |
194
|
|
|
$this->getLanguageHandler() |
195
|
|
|
), |
196
|
|
|
new Content\WordIndexer\Gateway\DoctrineDatabase( |
197
|
|
|
$this->getDatabaseHandler(), |
198
|
|
|
$this->getContentTypeHandler(), |
199
|
|
|
$transformationProcessor, |
200
|
|
|
new Content\WordIndexer\Repository\SearchIndex($this->getDatabaseHandler()), |
201
|
|
|
$this->getFullTextSearchConfiguration() |
202
|
|
|
), |
203
|
|
|
$this->createMock(ContentMapper::class), |
204
|
|
|
$this->getLocationMapperMock(), |
205
|
|
|
$this->getLanguageHandler(), |
206
|
|
|
$this->getFullTextMapper($this->getContentTypeHandler()) |
207
|
|
|
); |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
protected $contentTypeHandler; |
211
|
|
|
|
212
|
|
View Code Duplication |
protected function getContentTypeHandler() |
213
|
|
|
{ |
214
|
|
|
if (!isset($this->contentTypeHandler)) { |
215
|
|
|
$this->contentTypeHandler = new ContentTypeHandler( |
216
|
|
|
new ContentTypeGateway( |
217
|
|
|
$this->getDatabaseHandler(), |
218
|
|
|
$this->getLanguageMaskGenerator() |
219
|
|
|
), |
220
|
|
|
new ContentTypeMapper($this->getConverterRegistry()), |
221
|
|
|
$this->createMock(ContentTypeUpdateHandler::class) |
222
|
|
|
); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
return $this->contentTypeHandler; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
protected $fieldRegistry; |
229
|
|
|
|
230
|
|
View Code Duplication |
protected function getConverterRegistry() |
231
|
|
|
{ |
232
|
|
|
if (!isset($this->fieldRegistry)) { |
233
|
|
|
$this->fieldRegistry = new ConverterRegistry( |
234
|
|
|
[ |
235
|
|
|
'ezdatetime' => new Converter\DateAndTimeConverter(), |
236
|
|
|
'ezinteger' => new Converter\IntegerConverter(), |
237
|
|
|
'ezstring' => new Converter\TextLineConverter(), |
238
|
|
|
'ezprice' => new Converter\IntegerConverter(), |
239
|
|
|
'ezurl' => new Converter\UrlConverter(), |
240
|
|
|
'ezrichtext' => new Converter\RichTextConverter(), |
241
|
|
|
'ezboolean' => new Converter\CheckboxConverter(), |
242
|
|
|
'ezkeyword' => new Converter\KeywordConverter(), |
243
|
|
|
] |
244
|
|
|
); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $this->fieldRegistry; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Returns a location mapper mock. |
252
|
|
|
* |
253
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper |
254
|
|
|
*/ |
255
|
|
View Code Duplication |
protected function getLocationMapperMock() |
256
|
|
|
{ |
257
|
|
|
$mapperMock = $this->getMockBuilder(LocationMapper::class) |
258
|
|
|
->setMethods(['createLocationsFromRows']) |
259
|
|
|
->getMock(); |
260
|
|
|
$mapperMock |
261
|
|
|
->expects($this->any()) |
262
|
|
|
->method('createLocationsFromRows') |
263
|
|
|
->with($this->isType('array')) |
264
|
|
|
->will( |
265
|
|
|
$this->returnCallback( |
266
|
|
|
function ($rows) { |
267
|
|
|
$locations = []; |
268
|
|
|
foreach ($rows as $row) { |
269
|
|
|
$locationId = (int)$row['node_id']; |
270
|
|
|
if (!isset($locations[$locationId])) { |
271
|
|
|
$locations[$locationId] = new SPILocation(); |
272
|
|
|
$locations[$locationId]->id = $locationId; |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
return array_values($locations); |
277
|
|
|
} |
278
|
|
|
) |
279
|
|
|
); |
280
|
|
|
|
281
|
|
|
return $mapperMock; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public function testFindWithoutOffsetLimit() |
285
|
|
|
{ |
286
|
|
|
$handler = $this->getContentSearchHandler(); |
287
|
|
|
|
288
|
|
|
$searchResult = $handler->findLocations( |
289
|
|
|
new LocationQuery( |
290
|
|
|
[ |
291
|
|
|
'filter' => new Criterion\LocationId(2), |
292
|
|
|
] |
293
|
|
|
) |
294
|
|
|
); |
295
|
|
|
|
296
|
|
|
$this->assertEquals(1, $searchResult->totalCount); |
297
|
|
|
$this->assertCount(1, $searchResult->searchHits); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
View Code Duplication |
public function testFindWithZeroLimit() |
301
|
|
|
{ |
302
|
|
|
$handler = $this->getContentSearchHandler(); |
303
|
|
|
|
304
|
|
|
$searchResult = $handler->findLocations( |
305
|
|
|
new LocationQuery( |
306
|
|
|
[ |
307
|
|
|
'filter' => new Criterion\LocationId(2), |
308
|
|
|
'offset' => 0, |
309
|
|
|
'limit' => 0, |
310
|
|
|
] |
311
|
|
|
) |
312
|
|
|
); |
313
|
|
|
|
314
|
|
|
$this->assertEquals(1, $searchResult->totalCount); |
315
|
|
|
$this->assertEquals([], $searchResult->searchHits); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Issue with PHP_MAX_INT limit overflow in databases. |
320
|
|
|
*/ |
321
|
|
View Code Duplication |
public function testFindWithNullLimit() |
322
|
|
|
{ |
323
|
|
|
$handler = $this->getContentSearchHandler(); |
324
|
|
|
|
325
|
|
|
$searchResult = $handler->findLocations( |
326
|
|
|
new LocationQuery( |
327
|
|
|
[ |
328
|
|
|
'filter' => new Criterion\LocationId(2), |
329
|
|
|
'offset' => 0, |
330
|
|
|
'limit' => null, |
331
|
|
|
] |
332
|
|
|
) |
333
|
|
|
); |
334
|
|
|
|
335
|
|
|
$this->assertEquals(1, $searchResult->totalCount); |
336
|
|
|
$this->assertCount(1, $searchResult->searchHits); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Issue with offsetting to the nonexistent results produces \ezcQueryInvalidParameterException exception. |
341
|
|
|
*/ |
342
|
|
View Code Duplication |
public function testFindWithOffsetToNonexistent() |
343
|
|
|
{ |
344
|
|
|
$handler = $this->getContentSearchHandler(); |
345
|
|
|
|
346
|
|
|
$searchResult = $handler->findLocations( |
347
|
|
|
new LocationQuery( |
348
|
|
|
[ |
349
|
|
|
'filter' => new Criterion\LocationId(2), |
350
|
|
|
'offset' => 1000, |
351
|
|
|
'limit' => null, |
352
|
|
|
] |
353
|
|
|
) |
354
|
|
|
); |
355
|
|
|
|
356
|
|
|
$this->assertEquals(1, $searchResult->totalCount); |
357
|
|
|
$this->assertEquals([], $searchResult->searchHits); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
public function testLocationIdFilter() |
361
|
|
|
{ |
362
|
|
|
$this->assertSearchResults( |
363
|
|
|
[12, 13], |
364
|
|
|
$this->getContentSearchHandler()->findLocations( |
365
|
|
|
new LocationQuery( |
366
|
|
|
[ |
367
|
|
|
'filter' => new Criterion\LocationId( |
368
|
|
|
[4, 12, 13] |
369
|
|
|
), |
370
|
|
|
'limit' => 10, |
371
|
|
|
] |
372
|
|
|
) |
373
|
|
|
) |
374
|
|
|
); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
public function testParentLocationIdFilter() |
378
|
|
|
{ |
379
|
|
|
$this->assertSearchResults( |
380
|
|
|
[12, 13, 14, 44, 227], |
381
|
|
|
$this->getContentSearchHandler()->findLocations( |
382
|
|
|
new LocationQuery( |
383
|
|
|
[ |
384
|
|
|
'filter' => new Criterion\ParentLocationId(5), |
385
|
|
|
'limit' => 10, |
386
|
|
|
] |
387
|
|
|
) |
388
|
|
|
) |
389
|
|
|
); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
View Code Duplication |
public function testLocationIdAndCombinatorFilter() |
393
|
|
|
{ |
394
|
|
|
$this->assertSearchResults( |
395
|
|
|
[13], |
396
|
|
|
$this->getContentSearchHandler()->findLocations( |
397
|
|
|
new LocationQuery( |
398
|
|
|
[ |
399
|
|
|
'filter' => new Criterion\LogicalAnd( |
400
|
|
|
[ |
401
|
|
|
new Criterion\LocationId( |
402
|
|
|
[4, 12, 13] |
403
|
|
|
), |
404
|
|
|
new Criterion\LocationId( |
405
|
|
|
[13, 44] |
406
|
|
|
), |
407
|
|
|
] |
408
|
|
|
), |
409
|
|
|
'limit' => 10, |
410
|
|
|
] |
411
|
|
|
) |
412
|
|
|
) |
413
|
|
|
); |
414
|
|
|
} |
415
|
|
|
|
416
|
|
View Code Duplication |
public function testLocationIdParentLocationIdAndCombinatorFilter() |
417
|
|
|
{ |
418
|
|
|
$this->assertSearchResults( |
419
|
|
|
[44, 160], |
420
|
|
|
$this->getContentSearchHandler()->findLocations( |
421
|
|
|
new LocationQuery( |
422
|
|
|
[ |
423
|
|
|
'filter' => new Criterion\LogicalAnd( |
424
|
|
|
[ |
425
|
|
|
new Criterion\LocationId( |
426
|
|
|
[2, 44, 160, 166] |
427
|
|
|
), |
428
|
|
|
new Criterion\ParentLocationId( |
429
|
|
|
[5, 156] |
430
|
|
|
), |
431
|
|
|
] |
432
|
|
|
), |
433
|
|
|
'limit' => 10, |
434
|
|
|
] |
435
|
|
|
) |
436
|
|
|
) |
437
|
|
|
); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
public function testContentDepthFilterEq() |
441
|
|
|
{ |
442
|
|
|
$this->assertSearchResults( |
443
|
|
|
[2, 5, 43, 48, 58], |
444
|
|
|
$this->getContentSearchHandler()->findLocations( |
445
|
|
|
new LocationQuery( |
446
|
|
|
[ |
447
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::EQ, 1), |
448
|
|
|
'limit' => 10, |
449
|
|
|
] |
450
|
|
|
) |
451
|
|
|
) |
452
|
|
|
); |
453
|
|
|
} |
454
|
|
|
|
455
|
|
View Code Duplication |
public function testContentDepthFilterIn() |
456
|
|
|
{ |
457
|
|
|
$this->assertSearchResults( |
458
|
|
|
[2, 5, 12, 13, 14, 43, 44, 48, 51, 52, 53, 54, 56, 58, 59, 69, 77, 86, 96, 107, 153, 156, 167, 190, 227], |
459
|
|
|
$this->getContentSearchHandler()->findLocations( |
460
|
|
|
new LocationQuery( |
461
|
|
|
[ |
462
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::IN, [1, 2]), |
463
|
|
|
'limit' => 50, |
464
|
|
|
] |
465
|
|
|
) |
466
|
|
|
) |
467
|
|
|
); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
public function testContentDepthFilterBetween() |
471
|
|
|
{ |
472
|
|
|
$this->assertSearchResults( |
473
|
|
|
[2, 5, 43, 48, 58], |
474
|
|
|
$this->getContentSearchHandler()->findLocations( |
475
|
|
|
new LocationQuery( |
476
|
|
|
[ |
477
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::BETWEEN, [0, 1]), |
478
|
|
|
] |
479
|
|
|
) |
480
|
|
|
) |
481
|
|
|
); |
482
|
|
|
} |
483
|
|
|
|
484
|
|
View Code Duplication |
public function testContentDepthFilterGreaterThan() |
485
|
|
|
{ |
486
|
|
|
$this->assertSearchResults( |
487
|
|
|
[99, 102, 135, 136, 137, 139, 140, 142, 143, 144, 145, 148, 151, 174, 175, 177, 194, 196, 197, 198, 199, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 214, 215], |
488
|
|
|
$this->getContentSearchHandler()->findLocations( |
489
|
|
|
new LocationQuery( |
490
|
|
|
[ |
491
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::GT, 4), |
492
|
|
|
'limit' => 50, |
493
|
|
|
] |
494
|
|
|
) |
495
|
|
|
) |
496
|
|
|
); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
View Code Duplication |
public function testContentDepthFilterGreaterThanOrEqual() |
500
|
|
|
{ |
501
|
|
|
$this->assertSearchResults( |
502
|
|
|
[99, 102, 135, 136, 137, 139, 140, 142, 143, 144, 145, 148, 151, 174, 175, 177, 194, 196, 197, 198, 199, 200, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 212, 214, 215], |
503
|
|
|
$this->getContentSearchHandler()->findLocations( |
504
|
|
|
new LocationQuery( |
505
|
|
|
[ |
506
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::GTE, 5), |
507
|
|
|
'limit' => 50, |
508
|
|
|
] |
509
|
|
|
) |
510
|
|
|
) |
511
|
|
|
); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
public function testContentDepthFilterLessThan() |
515
|
|
|
{ |
516
|
|
|
$this->assertSearchResults( |
517
|
|
|
[2, 5, 43, 48, 58], |
518
|
|
|
$this->getContentSearchHandler()->findLocations( |
519
|
|
|
new LocationQuery( |
520
|
|
|
[ |
521
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::LT, 2), |
522
|
|
|
'limit' => 10, |
523
|
|
|
] |
524
|
|
|
) |
525
|
|
|
) |
526
|
|
|
); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
View Code Duplication |
public function testContentDepthFilterLessThanOrEqual() |
530
|
|
|
{ |
531
|
|
|
$this->assertSearchResults( |
532
|
|
|
[2, 5, 12, 13, 14, 43, 44, 48, 51, 52, 53, 54, 56, 58, 59, 69, 77, 86, 96, 107, 153, 156, 167, 190, 227], |
533
|
|
|
$this->getContentSearchHandler()->findLocations( |
534
|
|
|
new LocationQuery( |
535
|
|
|
[ |
536
|
|
|
'filter' => new Criterion\Location\Depth(Criterion\Operator::LTE, 2), |
537
|
|
|
'limit' => 50, |
538
|
|
|
] |
539
|
|
|
) |
540
|
|
|
) |
541
|
|
|
); |
542
|
|
|
} |
543
|
|
|
|
544
|
|
|
public function testLocationPriorityFilter() |
545
|
|
|
{ |
546
|
|
|
$this->assertSearchResults( |
547
|
|
|
[156, 167, 190], |
548
|
|
|
$this->getContentSearchHandler()->findLocations( |
549
|
|
|
new LocationQuery( |
550
|
|
|
[ |
551
|
|
|
'filter' => new Criterion\Location\Priority( |
552
|
|
|
Criterion\Operator::BETWEEN, |
553
|
|
|
[1, 10] |
554
|
|
|
), |
555
|
|
|
'limit' => 10, |
556
|
|
|
] |
557
|
|
|
) |
558
|
|
|
) |
559
|
|
|
); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
public function testLocationRemoteIdFilter() |
563
|
|
|
{ |
564
|
|
|
$this->assertSearchResults( |
565
|
|
|
[2, 5], |
566
|
|
|
$this->getContentSearchHandler()->findLocations( |
567
|
|
|
new LocationQuery( |
568
|
|
|
[ |
569
|
|
|
'filter' => new Criterion\LocationRemoteId( |
570
|
|
|
['3f6d92f8044aed134f32153517850f5a', 'f3e90596361e31d496d4026eb624c983'] |
571
|
|
|
), |
572
|
|
|
'limit' => 10, |
573
|
|
|
] |
574
|
|
|
) |
575
|
|
|
) |
576
|
|
|
); |
577
|
|
|
} |
578
|
|
|
|
579
|
|
View Code Duplication |
public function testVisibilityFilterVisible() |
580
|
|
|
{ |
581
|
|
|
$this->assertSearchResults( |
582
|
|
|
[2, 5, 12, 13, 14], |
583
|
|
|
$this->getContentSearchHandler()->findLocations( |
584
|
|
|
new LocationQuery( |
585
|
|
|
[ |
586
|
|
|
'filter' => new Criterion\Visibility( |
587
|
|
|
Criterion\Visibility::VISIBLE |
588
|
|
|
), |
589
|
|
|
'limit' => 5, |
590
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
591
|
|
|
] |
592
|
|
|
) |
593
|
|
|
) |
594
|
|
|
); |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
public function testVisibilityFilterHidden() |
598
|
|
|
{ |
599
|
|
|
$this->assertSearchResults( |
600
|
|
|
[228], |
601
|
|
|
$this->getContentSearchHandler()->findLocations( |
602
|
|
|
new LocationQuery( |
603
|
|
|
[ |
604
|
|
|
'filter' => new Criterion\Visibility( |
605
|
|
|
Criterion\Visibility::HIDDEN |
606
|
|
|
), |
607
|
|
|
] |
608
|
|
|
) |
609
|
|
|
) |
610
|
|
|
); |
611
|
|
|
} |
612
|
|
|
|
613
|
|
View Code Duplication |
public function testLocationNotCombinatorFilter() |
614
|
|
|
{ |
615
|
|
|
$this->assertSearchResults( |
616
|
|
|
[2, 5], |
617
|
|
|
$this->getContentSearchHandler()->findLocations( |
618
|
|
|
new LocationQuery( |
619
|
|
|
[ |
620
|
|
|
'filter' => new Criterion\LogicalAnd( |
621
|
|
|
[ |
622
|
|
|
new Criterion\LocationId( |
623
|
|
|
[2, 5, 12, 356] |
624
|
|
|
), |
625
|
|
|
new Criterion\LogicalNot( |
626
|
|
|
new Criterion\LocationId( |
627
|
|
|
[12, 13, 14] |
628
|
|
|
) |
629
|
|
|
), |
630
|
|
|
] |
631
|
|
|
), |
632
|
|
|
'limit' => 10, |
633
|
|
|
] |
634
|
|
|
) |
635
|
|
|
) |
636
|
|
|
); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
public function testLocationOrCombinatorFilter() |
640
|
|
|
{ |
641
|
|
|
$this->assertSearchResults( |
642
|
|
|
[2, 5, 12, 13, 14], |
643
|
|
|
$this->getContentSearchHandler()->findLocations( |
644
|
|
|
new LocationQuery( |
645
|
|
|
[ |
646
|
|
|
'filter' => new Criterion\LogicalOr( |
647
|
|
|
[ |
648
|
|
|
new Criterion\LocationId( |
649
|
|
|
[2, 5, 12] |
650
|
|
|
), |
651
|
|
|
new Criterion\LocationId( |
652
|
|
|
[12, 13, 14] |
653
|
|
|
), |
654
|
|
|
] |
655
|
|
|
), |
656
|
|
|
'limit' => 10, |
657
|
|
|
] |
658
|
|
|
) |
659
|
|
|
) |
660
|
|
|
); |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
public function testContentIdFilterEquals() |
664
|
|
|
{ |
665
|
|
|
$this->assertSearchResults( |
666
|
|
|
[225], |
667
|
|
|
$this->getContentSearchHandler()->findLocations( |
668
|
|
|
new LocationQuery( |
669
|
|
|
[ |
670
|
|
|
'filter' => new Criterion\ContentId(223), |
671
|
|
|
] |
672
|
|
|
) |
673
|
|
|
) |
674
|
|
|
); |
675
|
|
|
} |
676
|
|
|
|
677
|
|
|
public function testContentIdFilterIn() |
678
|
|
|
{ |
679
|
|
|
$this->assertSearchResults( |
680
|
|
|
[225, 226, 227], |
681
|
|
|
$this->getContentSearchHandler()->findLocations( |
682
|
|
|
new LocationQuery( |
683
|
|
|
[ |
684
|
|
|
'filter' => new Criterion\ContentId( |
685
|
|
|
[223, 224, 225] |
686
|
|
|
), |
687
|
|
|
] |
688
|
|
|
) |
689
|
|
|
) |
690
|
|
|
); |
691
|
|
|
} |
692
|
|
|
|
693
|
|
View Code Duplication |
public function testContentTypeGroupFilter() |
694
|
|
|
{ |
695
|
|
|
$this->assertSearchResults( |
696
|
|
|
[5, 12, 13, 14, 15, 44, 45, 227, 228], |
697
|
|
|
$this->getContentSearchHandler()->findLocations( |
698
|
|
|
new LocationQuery( |
699
|
|
|
[ |
700
|
|
|
'filter' => new Criterion\ContentTypeGroupId(2), |
701
|
|
|
'limit' => 10, |
702
|
|
|
] |
703
|
|
|
) |
704
|
|
|
) |
705
|
|
|
); |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
public function testContentTypeIdFilter() |
709
|
|
|
{ |
710
|
|
|
$this->assertSearchResults( |
711
|
|
|
[15, 45, 228], |
712
|
|
|
$this->getContentSearchHandler()->findLocations( |
713
|
|
|
new LocationQuery( |
714
|
|
|
[ |
715
|
|
|
'filter' => new Criterion\ContentTypeId(4), |
716
|
|
|
'limit' => 10, |
717
|
|
|
] |
718
|
|
|
) |
719
|
|
|
) |
720
|
|
|
); |
721
|
|
|
} |
722
|
|
|
|
723
|
|
View Code Duplication |
public function testContentTypeIdentifierFilter() |
724
|
|
|
{ |
725
|
|
|
$this->assertSearchResults( |
726
|
|
|
[43, 48, 51, 52, 53], |
727
|
|
|
$this->getContentSearchHandler()->findLocations( |
728
|
|
|
new LocationQuery( |
729
|
|
|
[ |
730
|
|
|
'filter' => new Criterion\ContentTypeIdentifier('folder'), |
731
|
|
|
'limit' => 5, |
732
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
733
|
|
|
] |
734
|
|
|
) |
735
|
|
|
) |
736
|
|
|
); |
737
|
|
|
} |
738
|
|
|
|
739
|
|
View Code Duplication |
public function testObjectStateIdFilter() |
740
|
|
|
{ |
741
|
|
|
$this->assertSearchResults( |
742
|
|
|
[5, 12, 13, 14, 15, 43, 44, 45, 48, 51], |
743
|
|
|
$this->getContentSearchHandler()->findLocations( |
744
|
|
|
new LocationQuery( |
745
|
|
|
[ |
746
|
|
|
'filter' => new Criterion\ObjectStateId(1), |
747
|
|
|
'limit' => 10, |
748
|
|
|
'sortClauses' => [new SortClause\ContentId()], |
749
|
|
|
] |
750
|
|
|
) |
751
|
|
|
) |
752
|
|
|
); |
753
|
|
|
} |
754
|
|
|
|
755
|
|
|
public function testObjectStateIdFilterIn() |
756
|
|
|
{ |
757
|
|
|
$this->assertSearchResults( |
758
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48], |
759
|
|
|
$this->getContentSearchHandler()->findLocations( |
760
|
|
|
new LocationQuery( |
761
|
|
|
[ |
762
|
|
|
'filter' => new Criterion\ObjectStateId([1, 2]), |
763
|
|
|
'limit' => 10, |
764
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
765
|
|
|
] |
766
|
|
|
) |
767
|
|
|
) |
768
|
|
|
); |
769
|
|
|
} |
770
|
|
|
|
771
|
|
|
public function testRemoteIdFilter() |
772
|
|
|
{ |
773
|
|
|
$this->assertSearchResults( |
774
|
|
|
[5, 45], |
775
|
|
|
$this->getContentSearchHandler()->findLocations( |
776
|
|
|
new LocationQuery( |
777
|
|
|
[ |
778
|
|
|
'filter' => new Criterion\RemoteId( |
779
|
|
|
['f5c88a2209584891056f987fd965b0ba', 'faaeb9be3bd98ed09f606fc16d144eca'] |
780
|
|
|
), |
781
|
|
|
'limit' => 10, |
782
|
|
|
] |
783
|
|
|
) |
784
|
|
|
) |
785
|
|
|
); |
786
|
|
|
} |
787
|
|
|
|
788
|
|
View Code Duplication |
public function testSectionFilter() |
789
|
|
|
{ |
790
|
|
|
$this->assertSearchResults( |
791
|
|
|
[5, 12, 13, 14, 15, 44, 45, 228], |
792
|
|
|
$this->getContentSearchHandler()->findLocations( |
793
|
|
|
new LocationQuery( |
794
|
|
|
[ |
795
|
|
|
'filter' => new Criterion\SectionId([2]), |
796
|
|
|
'limit' => 10, |
797
|
|
|
] |
798
|
|
|
) |
799
|
|
|
) |
800
|
|
|
); |
801
|
|
|
} |
802
|
|
|
|
803
|
|
|
public function testDateMetadataFilterModifiedGreater() |
804
|
|
|
{ |
805
|
|
|
$this->assertSearchResults( |
806
|
|
|
[12, 227, 228], |
807
|
|
|
$this->getContentSearchHandler()->findLocations( |
808
|
|
|
new LocationQuery( |
809
|
|
|
[ |
810
|
|
|
'filter' => new Criterion\DateMetadata( |
811
|
|
|
Criterion\DateMetadata::MODIFIED, |
812
|
|
|
Criterion\Operator::GT, |
813
|
|
|
1311154214 |
814
|
|
|
), |
815
|
|
|
'limit' => 10, |
816
|
|
|
] |
817
|
|
|
) |
818
|
|
|
) |
819
|
|
|
); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
public function testDateMetadataFilterModifiedGreaterOrEqual() |
823
|
|
|
{ |
824
|
|
|
$this->assertSearchResults( |
825
|
|
|
[12, 15, 227, 228], |
826
|
|
|
$this->getContentSearchHandler()->findLocations( |
827
|
|
|
new LocationQuery( |
828
|
|
|
[ |
829
|
|
|
'filter' => new Criterion\DateMetadata( |
830
|
|
|
Criterion\DateMetadata::MODIFIED, |
831
|
|
|
Criterion\Operator::GTE, |
832
|
|
|
1311154214 |
833
|
|
|
), |
834
|
|
|
'limit' => 10, |
835
|
|
|
] |
836
|
|
|
) |
837
|
|
|
) |
838
|
|
|
); |
839
|
|
|
} |
840
|
|
|
|
841
|
|
View Code Duplication |
public function testDateMetadataFilterModifiedIn() |
842
|
|
|
{ |
843
|
|
|
$this->assertSearchResults( |
844
|
|
|
[12, 15, 227, 228], |
845
|
|
|
$this->getContentSearchHandler()->findLocations( |
846
|
|
|
new LocationQuery( |
847
|
|
|
[ |
848
|
|
|
'filter' => new Criterion\DateMetadata( |
849
|
|
|
Criterion\DateMetadata::MODIFIED, |
850
|
|
|
Criterion\Operator::IN, |
851
|
|
|
[1311154214, 1311154215] |
852
|
|
|
), |
853
|
|
|
'limit' => 10, |
854
|
|
|
] |
855
|
|
|
) |
856
|
|
|
) |
857
|
|
|
); |
858
|
|
|
} |
859
|
|
|
|
860
|
|
View Code Duplication |
public function testDateMetadataFilterModifiedBetween() |
861
|
|
|
{ |
862
|
|
|
$this->assertSearchResults( |
863
|
|
|
[12, 15, 227, 228], |
864
|
|
|
$this->getContentSearchHandler()->findLocations( |
865
|
|
|
new LocationQuery( |
866
|
|
|
[ |
867
|
|
|
'filter' => new Criterion\DateMetadata( |
868
|
|
|
Criterion\DateMetadata::MODIFIED, |
869
|
|
|
Criterion\Operator::BETWEEN, |
870
|
|
|
[1311154213, 1311154215] |
871
|
|
|
), |
872
|
|
|
'limit' => 10, |
873
|
|
|
] |
874
|
|
|
) |
875
|
|
|
) |
876
|
|
|
); |
877
|
|
|
} |
878
|
|
|
|
879
|
|
View Code Duplication |
public function testDateMetadataFilterCreatedBetween() |
880
|
|
|
{ |
881
|
|
|
$this->assertSearchResults( |
882
|
|
|
[68, 133, 227], |
883
|
|
|
$this->getContentSearchHandler()->findLocations( |
884
|
|
|
new LocationQuery( |
885
|
|
|
[ |
886
|
|
|
'filter' => new Criterion\DateMetadata( |
887
|
|
|
Criterion\DateMetadata::CREATED, |
888
|
|
|
Criterion\Operator::BETWEEN, |
889
|
|
|
[1299780749, 1311154215] |
890
|
|
|
), |
891
|
|
|
'limit' => 10, |
892
|
|
|
] |
893
|
|
|
) |
894
|
|
|
) |
895
|
|
|
); |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
public function testUserMetadataFilterOwnerWrongUserId() |
899
|
|
|
{ |
900
|
|
|
$this->assertSearchResults( |
901
|
|
|
[], |
902
|
|
|
$this->getContentSearchHandler()->findLocations( |
903
|
|
|
new LocationQuery( |
904
|
|
|
[ |
905
|
|
|
'filter' => new Criterion\UserMetadata( |
906
|
|
|
Criterion\UserMetadata::OWNER, |
907
|
|
|
Criterion\Operator::EQ, |
908
|
|
|
2 |
909
|
|
|
), |
910
|
|
|
] |
911
|
|
|
) |
912
|
|
|
) |
913
|
|
|
); |
914
|
|
|
} |
915
|
|
|
|
916
|
|
View Code Duplication |
public function testUserMetadataFilterOwnerAdministrator() |
917
|
|
|
{ |
918
|
|
|
$this->assertSearchResults( |
919
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48], |
920
|
|
|
$this->getContentSearchHandler()->findLocations( |
921
|
|
|
new LocationQuery( |
922
|
|
|
[ |
923
|
|
|
'filter' => new Criterion\UserMetadata( |
924
|
|
|
Criterion\UserMetadata::OWNER, |
925
|
|
|
Criterion\Operator::EQ, |
926
|
|
|
14 |
927
|
|
|
), |
928
|
|
|
'limit' => 10, |
929
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
930
|
|
|
] |
931
|
|
|
) |
932
|
|
|
) |
933
|
|
|
); |
934
|
|
|
} |
935
|
|
|
|
936
|
|
|
public function testUserMetadataFilterOwnerEqAMember() |
937
|
|
|
{ |
938
|
|
|
$this->assertSearchResults( |
939
|
|
|
[225], |
940
|
|
|
$this->getContentSearchHandler()->findLocations( |
941
|
|
|
new LocationQuery( |
942
|
|
|
[ |
943
|
|
|
'filter' => new Criterion\UserMetadata( |
944
|
|
|
Criterion\UserMetadata::OWNER, |
945
|
|
|
Criterion\Operator::EQ, |
946
|
|
|
226 |
947
|
|
|
), |
948
|
|
|
] |
949
|
|
|
) |
950
|
|
|
) |
951
|
|
|
); |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
public function testUserMetadataFilterOwnerInAMember() |
955
|
|
|
{ |
956
|
|
|
$this->assertSearchResults( |
957
|
|
|
[225], |
958
|
|
|
$this->getContentSearchHandler()->findLocations( |
959
|
|
|
new LocationQuery( |
960
|
|
|
[ |
961
|
|
|
'filter' => new Criterion\UserMetadata( |
962
|
|
|
Criterion\UserMetadata::OWNER, |
963
|
|
|
Criterion\Operator::IN, |
964
|
|
|
[226] |
965
|
|
|
), |
966
|
|
|
] |
967
|
|
|
) |
968
|
|
|
) |
969
|
|
|
); |
970
|
|
|
} |
971
|
|
|
|
972
|
|
|
public function testUserMetadataFilterCreatorEqAMember() |
973
|
|
|
{ |
974
|
|
|
$this->assertSearchResults( |
975
|
|
|
[225], |
976
|
|
|
$this->getContentSearchHandler()->findLocations( |
977
|
|
|
new LocationQuery( |
978
|
|
|
[ |
979
|
|
|
'filter' => new Criterion\UserMetadata( |
980
|
|
|
Criterion\UserMetadata::MODIFIER, |
981
|
|
|
Criterion\Operator::EQ, |
982
|
|
|
226 |
983
|
|
|
), |
984
|
|
|
] |
985
|
|
|
) |
986
|
|
|
) |
987
|
|
|
); |
988
|
|
|
} |
989
|
|
|
|
990
|
|
|
public function testUserMetadataFilterCreatorInAMember() |
991
|
|
|
{ |
992
|
|
|
$this->assertSearchResults( |
993
|
|
|
[225], |
994
|
|
|
$this->getContentSearchHandler()->findLocations( |
995
|
|
|
new LocationQuery( |
996
|
|
|
[ |
997
|
|
|
'filter' => new Criterion\UserMetadata( |
998
|
|
|
Criterion\UserMetadata::MODIFIER, |
999
|
|
|
Criterion\Operator::IN, |
1000
|
|
|
[226] |
1001
|
|
|
), |
1002
|
|
|
] |
1003
|
|
|
) |
1004
|
|
|
) |
1005
|
|
|
); |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
public function testUserMetadataFilterEqGroupMember() |
1009
|
|
|
{ |
1010
|
|
|
$this->assertSearchResults( |
1011
|
|
|
[225], |
1012
|
|
|
$this->getContentSearchHandler()->findLocations( |
1013
|
|
|
new LocationQuery( |
1014
|
|
|
[ |
1015
|
|
|
'filter' => new Criterion\UserMetadata( |
1016
|
|
|
Criterion\UserMetadata::GROUP, |
1017
|
|
|
Criterion\Operator::EQ, |
1018
|
|
|
11 |
1019
|
|
|
), |
1020
|
|
|
] |
1021
|
|
|
) |
1022
|
|
|
) |
1023
|
|
|
); |
1024
|
|
|
} |
1025
|
|
|
|
1026
|
|
|
public function testUserMetadataFilterInGroupMember() |
1027
|
|
|
{ |
1028
|
|
|
$this->assertSearchResults( |
1029
|
|
|
[225], |
1030
|
|
|
$this->getContentSearchHandler()->findLocations( |
1031
|
|
|
new LocationQuery( |
1032
|
|
|
[ |
1033
|
|
|
'filter' => new Criterion\UserMetadata( |
1034
|
|
|
Criterion\UserMetadata::GROUP, |
1035
|
|
|
Criterion\Operator::IN, |
1036
|
|
|
[11] |
1037
|
|
|
), |
1038
|
|
|
] |
1039
|
|
|
) |
1040
|
|
|
) |
1041
|
|
|
); |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
|
|
public function testUserMetadataFilterEqGroupMemberNoMatch() |
1045
|
|
|
{ |
1046
|
|
|
$this->assertSearchResults( |
1047
|
|
|
[], |
1048
|
|
|
$this->getContentSearchHandler()->findLocations( |
1049
|
|
|
new LocationQuery( |
1050
|
|
|
[ |
1051
|
|
|
'filter' => new Criterion\UserMetadata( |
1052
|
|
|
Criterion\UserMetadata::GROUP, |
1053
|
|
|
Criterion\Operator::EQ, |
1054
|
|
|
13 |
1055
|
|
|
), |
1056
|
|
|
] |
1057
|
|
|
) |
1058
|
|
|
) |
1059
|
|
|
); |
1060
|
|
|
} |
1061
|
|
|
|
1062
|
|
|
public function testUserMetadataFilterInGroupMemberNoMatch() |
1063
|
|
|
{ |
1064
|
|
|
$this->assertSearchResults( |
1065
|
|
|
[], |
1066
|
|
|
$this->getContentSearchHandler()->findLocations( |
1067
|
|
|
new LocationQuery( |
1068
|
|
|
[ |
1069
|
|
|
'filter' => new Criterion\UserMetadata( |
1070
|
|
|
Criterion\UserMetadata::GROUP, |
1071
|
|
|
Criterion\Operator::IN, |
1072
|
|
|
[13] |
1073
|
|
|
), |
1074
|
|
|
] |
1075
|
|
|
) |
1076
|
|
|
) |
1077
|
|
|
); |
1078
|
|
|
} |
1079
|
|
|
|
1080
|
|
View Code Duplication |
public function testLanguageCodeFilter() |
1081
|
|
|
{ |
1082
|
|
|
$this->assertSearchResults( |
1083
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48], |
1084
|
|
|
$this->getContentSearchHandler()->findLocations( |
1085
|
|
|
new LocationQuery( |
1086
|
|
|
[ |
1087
|
|
|
'filter' => new Criterion\LanguageCode('eng-US'), |
1088
|
|
|
'limit' => 10, |
1089
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
1090
|
|
|
] |
1091
|
|
|
) |
1092
|
|
|
) |
1093
|
|
|
); |
1094
|
|
|
} |
1095
|
|
|
|
1096
|
|
|
public function testLanguageCodeFilterIn() |
1097
|
|
|
{ |
1098
|
|
|
$this->assertSearchResults( |
1099
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48], |
1100
|
|
|
$this->getContentSearchHandler()->findLocations( |
1101
|
|
|
new LocationQuery( |
1102
|
|
|
[ |
1103
|
|
|
'filter' => new Criterion\LanguageCode(['eng-US', 'eng-GB']), |
1104
|
|
|
'limit' => 10, |
1105
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
1106
|
|
|
] |
1107
|
|
|
) |
1108
|
|
|
) |
1109
|
|
|
); |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
View Code Duplication |
public function testLanguageCodeFilterWithAlwaysAvailable() |
1113
|
|
|
{ |
1114
|
|
|
$this->assertSearchResults( |
1115
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48, 51, 52, 53, 58, 59, 70, 72, 76, 78, 82], |
1116
|
|
|
$this->getContentSearchHandler()->findLocations( |
1117
|
|
|
new LocationQuery( |
1118
|
|
|
[ |
1119
|
|
|
'filter' => new Criterion\LanguageCode('eng-GB', true), |
1120
|
|
|
'limit' => 20, |
1121
|
|
|
'sortClauses' => [new SortClause\ContentId()], |
1122
|
|
|
] |
1123
|
|
|
) |
1124
|
|
|
) |
1125
|
|
|
); |
1126
|
|
|
} |
1127
|
|
|
|
1128
|
|
|
public function testMatchAllFilter() |
1129
|
|
|
{ |
1130
|
|
|
$result = $this->getContentSearchHandler()->findLocations( |
1131
|
|
|
new LocationQuery( |
1132
|
|
|
[ |
1133
|
|
|
'filter' => new Criterion\MatchAll(), |
1134
|
|
|
'limit' => 10, |
1135
|
|
|
'sortClauses' => [new SortClause\Location\Id()], |
1136
|
|
|
] |
1137
|
|
|
) |
1138
|
|
|
); |
1139
|
|
|
|
1140
|
|
|
$this->assertCount(10, $result->searchHits); |
1141
|
|
|
$this->assertEquals(186, $result->totalCount); |
1142
|
|
|
$this->assertSearchResults( |
1143
|
|
|
[2, 5, 12, 13, 14, 15, 43, 44, 45, 48], |
1144
|
|
|
$result |
1145
|
|
|
); |
1146
|
|
|
} |
1147
|
|
|
|
1148
|
|
|
public function testFullTextFilter() |
1149
|
|
|
{ |
1150
|
|
|
$this->assertSearchResults( |
1151
|
|
|
[193], |
1152
|
|
|
$this->getContentSearchHandler()->findLocations( |
1153
|
|
|
new LocationQuery( |
1154
|
|
|
[ |
1155
|
|
|
'filter' => new Criterion\FullText('applied webpage'), |
1156
|
|
|
'limit' => 10, |
1157
|
|
|
] |
1158
|
|
|
) |
1159
|
|
|
) |
1160
|
|
|
); |
1161
|
|
|
} |
1162
|
|
|
|
1163
|
|
|
public function testFullTextWildcardFilter() |
1164
|
|
|
{ |
1165
|
|
|
$this->assertSearchResults( |
1166
|
|
|
[193], |
1167
|
|
|
$this->getContentSearchHandler()->findLocations( |
1168
|
|
|
new LocationQuery( |
1169
|
|
|
[ |
1170
|
|
|
'filter' => new Criterion\FullText('applie*'), |
1171
|
|
|
'limit' => 10, |
1172
|
|
|
] |
1173
|
|
|
) |
1174
|
|
|
) |
1175
|
|
|
); |
1176
|
|
|
} |
1177
|
|
|
|
1178
|
|
|
public function testFullTextDisabledWildcardFilter() |
1179
|
|
|
{ |
1180
|
|
|
$this->assertSearchResults( |
1181
|
|
|
[], |
1182
|
|
|
$this->getContentSearchHandler(['enableWildcards' => false])->findLocations( |
1183
|
|
|
new LocationQuery( |
1184
|
|
|
[ |
1185
|
|
|
'filter' => new Criterion\FullText('applie*'), |
1186
|
|
|
'limit' => 10, |
1187
|
|
|
] |
1188
|
|
|
) |
1189
|
|
|
) |
1190
|
|
|
); |
1191
|
|
|
} |
1192
|
|
|
|
1193
|
|
|
public function testFullTextFilterStopwordRemoval() |
1194
|
|
|
{ |
1195
|
|
|
$handler = $this->getContentSearchHandler( |
1196
|
|
|
[ |
1197
|
|
|
'stopWordThresholdFactor' => 0.1, |
1198
|
|
|
] |
1199
|
|
|
); |
1200
|
|
|
$this->assertSearchResults( |
1201
|
|
|
[], |
1202
|
|
|
$handler->findLocations( |
1203
|
|
|
new LocationQuery( |
1204
|
|
|
[ |
1205
|
|
|
'filter' => new Criterion\FullText('the'), |
1206
|
|
|
'limit' => 10, |
1207
|
|
|
] |
1208
|
|
|
) |
1209
|
|
|
) |
1210
|
|
|
); |
1211
|
|
|
} |
1212
|
|
|
|
1213
|
|
|
public function testFullTextFilterNoStopwordRemoval() |
1214
|
|
|
{ |
1215
|
|
|
$handler = $this->getContentSearchHandler( |
1216
|
|
|
[ |
1217
|
|
|
'stopWordThresholdFactor' => 1, |
1218
|
|
|
] |
1219
|
|
|
); |
1220
|
|
|
|
1221
|
|
|
$result = $handler->findLocations( |
1222
|
|
|
new LocationQuery( |
1223
|
|
|
[ |
1224
|
|
|
'filter' => new Criterion\FullText( |
1225
|
|
|
'the' |
1226
|
|
|
), |
1227
|
|
|
'limit' => 10, |
1228
|
|
|
] |
1229
|
|
|
) |
1230
|
|
|
); |
1231
|
|
|
|
1232
|
|
|
$this->assertEquals(26, $result->totalCount); |
1233
|
|
|
$this->assertCount(10, $result->searchHits); |
1234
|
|
|
$this->assertEquals( |
1235
|
|
|
10, |
1236
|
|
|
count( |
1237
|
|
|
array_map( |
1238
|
|
|
function ($hit) { |
1239
|
|
|
return $hit->valueObject->id; |
1240
|
|
|
}, |
1241
|
|
|
$result->searchHits |
1242
|
|
|
) |
1243
|
|
|
) |
1244
|
|
|
); |
1245
|
|
|
} |
1246
|
|
|
|
1247
|
|
|
/** |
1248
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
1249
|
|
|
*/ |
1250
|
|
|
public function testFullTextFilterInvalidStopwordThreshold() |
1251
|
|
|
{ |
1252
|
|
|
$this->getContentSearchHandler( |
1253
|
|
|
[ |
1254
|
|
|
'stopWordThresholdFactor' => 2, |
1255
|
|
|
] |
1256
|
|
|
); |
1257
|
|
|
} |
1258
|
|
|
|
1259
|
|
|
public function testFieldRelationFilterContainsSingle() |
1260
|
|
|
{ |
1261
|
|
|
$this->assertSearchResults( |
1262
|
|
|
[69], |
1263
|
|
|
$this->getContentSearchHandler()->findLocations( |
1264
|
|
|
new LocationQuery( |
1265
|
|
|
[ |
1266
|
|
|
'filter' => new Criterion\FieldRelation( |
1267
|
|
|
'billboard', |
1268
|
|
|
Criterion\Operator::CONTAINS, |
1269
|
|
|
[60] |
1270
|
|
|
), |
1271
|
|
|
] |
1272
|
|
|
) |
1273
|
|
|
) |
1274
|
|
|
); |
1275
|
|
|
} |
1276
|
|
|
|
1277
|
|
|
public function testFieldRelationFilterContainsSingleNoMatch() |
1278
|
|
|
{ |
1279
|
|
|
$this->assertSearchResults( |
1280
|
|
|
[], |
1281
|
|
|
$this->getContentSearchHandler()->findLocations( |
1282
|
|
|
new LocationQuery( |
1283
|
|
|
[ |
1284
|
|
|
'filter' => new Criterion\FieldRelation( |
1285
|
|
|
'billboard', |
1286
|
|
|
Criterion\Operator::CONTAINS, |
1287
|
|
|
[4] |
1288
|
|
|
), |
1289
|
|
|
] |
1290
|
|
|
) |
1291
|
|
|
) |
1292
|
|
|
); |
1293
|
|
|
} |
1294
|
|
|
|
1295
|
|
View Code Duplication |
public function testFieldRelationFilterContainsArray() |
1296
|
|
|
{ |
1297
|
|
|
$this->assertSearchResults( |
1298
|
|
|
[69], |
1299
|
|
|
$this->getContentSearchHandler()->findLocations( |
1300
|
|
|
new LocationQuery( |
1301
|
|
|
[ |
1302
|
|
|
'filter' => new Criterion\FieldRelation( |
1303
|
|
|
'billboard', |
1304
|
|
|
Criterion\Operator::CONTAINS, |
1305
|
|
|
[60, 75] |
1306
|
|
|
), |
1307
|
|
|
] |
1308
|
|
|
) |
1309
|
|
|
) |
1310
|
|
|
); |
1311
|
|
|
} |
1312
|
|
|
|
1313
|
|
|
public function testFieldRelationFilterContainsArrayNotMatch() |
1314
|
|
|
{ |
1315
|
|
|
$this->assertSearchResults( |
1316
|
|
|
[], |
1317
|
|
|
$this->getContentSearchHandler()->findLocations( |
1318
|
|
|
new LocationQuery( |
1319
|
|
|
[ |
1320
|
|
|
'filter' => new Criterion\FieldRelation( |
1321
|
|
|
'billboard', |
1322
|
|
|
Criterion\Operator::CONTAINS, |
1323
|
|
|
[60, 64] |
1324
|
|
|
), |
1325
|
|
|
] |
1326
|
|
|
) |
1327
|
|
|
) |
1328
|
|
|
); |
1329
|
|
|
} |
1330
|
|
|
|
1331
|
|
View Code Duplication |
public function testFieldRelationFilterInArray() |
1332
|
|
|
{ |
1333
|
|
|
$this->assertSearchResults( |
1334
|
|
|
[69, 77], |
1335
|
|
|
$this->getContentSearchHandler()->findLocations( |
1336
|
|
|
new LocationQuery( |
1337
|
|
|
[ |
1338
|
|
|
'filter' => new Criterion\FieldRelation( |
1339
|
|
|
'billboard', |
1340
|
|
|
Criterion\Operator::IN, |
1341
|
|
|
[60, 64] |
1342
|
|
|
), |
1343
|
|
|
] |
1344
|
|
|
) |
1345
|
|
|
) |
1346
|
|
|
); |
1347
|
|
|
} |
1348
|
|
|
|
1349
|
|
|
public function testFieldRelationFilterInArrayNotMatch() |
1350
|
|
|
{ |
1351
|
|
|
$this->assertSearchResults( |
1352
|
|
|
[], |
1353
|
|
|
$this->getContentSearchHandler()->findLocations( |
1354
|
|
|
new LocationQuery( |
1355
|
|
|
[ |
1356
|
|
|
'filter' => new Criterion\FieldRelation( |
1357
|
|
|
'billboard', |
1358
|
|
|
Criterion\Operator::IN, |
1359
|
|
|
[4, 10] |
1360
|
|
|
), |
1361
|
|
|
] |
1362
|
|
|
) |
1363
|
|
|
) |
1364
|
|
|
); |
1365
|
|
|
} |
1366
|
|
|
|
1367
|
|
|
public function testFieldFilter() |
1368
|
|
|
{ |
1369
|
|
|
$this->assertSearchResults( |
1370
|
|
|
[12], |
1371
|
|
|
$this->getContentSearchHandler()->findLocations( |
1372
|
|
|
new LocationQuery( |
1373
|
|
|
[ |
1374
|
|
|
'filter' => new Criterion\Field( |
1375
|
|
|
'name', |
1376
|
|
|
Criterion\Operator::EQ, |
1377
|
|
|
'members' |
1378
|
|
|
), |
1379
|
|
|
'limit' => 10, |
1380
|
|
|
] |
1381
|
|
|
) |
1382
|
|
|
) |
1383
|
|
|
); |
1384
|
|
|
} |
1385
|
|
|
|
1386
|
|
View Code Duplication |
public function testFieldFilterIn() |
1387
|
|
|
{ |
1388
|
|
|
$this->assertSearchResults( |
1389
|
|
|
[12, 44], |
1390
|
|
|
$this->getContentSearchHandler()->findLocations( |
1391
|
|
|
new LocationQuery( |
1392
|
|
|
[ |
1393
|
|
|
'filter' => new Criterion\Field( |
1394
|
|
|
'name', |
1395
|
|
|
Criterion\Operator::IN, |
1396
|
|
|
['members', 'anonymous users'] |
1397
|
|
|
), |
1398
|
|
|
'limit' => 10, |
1399
|
|
|
] |
1400
|
|
|
) |
1401
|
|
|
) |
1402
|
|
|
); |
1403
|
|
|
} |
1404
|
|
|
|
1405
|
|
|
public function testFieldFilterContainsPartial() |
1406
|
|
|
{ |
1407
|
|
|
$this->assertSearchResults( |
1408
|
|
|
[44], |
1409
|
|
|
$this->getContentSearchHandler()->findLocations( |
1410
|
|
|
new LocationQuery( |
1411
|
|
|
[ |
1412
|
|
|
'filter' => new Criterion\Field( |
1413
|
|
|
'name', |
1414
|
|
|
Criterion\Operator::CONTAINS, |
1415
|
|
|
'nonymous use' |
1416
|
|
|
), |
1417
|
|
|
'limit' => 10, |
1418
|
|
|
] |
1419
|
|
|
) |
1420
|
|
|
) |
1421
|
|
|
); |
1422
|
|
|
} |
1423
|
|
|
|
1424
|
|
|
public function testFieldFilterContainsSimple() |
1425
|
|
|
{ |
1426
|
|
|
$this->assertSearchResults( |
1427
|
|
|
[79], |
1428
|
|
|
$this->getContentSearchHandler()->findLocations( |
1429
|
|
|
new LocationQuery( |
1430
|
|
|
[ |
1431
|
|
|
'filter' => new Criterion\Field( |
1432
|
|
|
'publish_date', |
1433
|
|
|
Criterion\Operator::CONTAINS, |
1434
|
|
|
1174643880 |
1435
|
|
|
), |
1436
|
|
|
'limit' => 10, |
1437
|
|
|
] |
1438
|
|
|
) |
1439
|
|
|
) |
1440
|
|
|
); |
1441
|
|
|
} |
1442
|
|
|
|
1443
|
|
|
public function testFieldFilterContainsSimpleNoMatch() |
1444
|
|
|
{ |
1445
|
|
|
$this->assertSearchResults( |
1446
|
|
|
[], |
1447
|
|
|
$this->getContentSearchHandler()->findLocations( |
1448
|
|
|
new LocationQuery( |
1449
|
|
|
[ |
1450
|
|
|
'filter' => new Criterion\Field( |
1451
|
|
|
'publish_date', |
1452
|
|
|
Criterion\Operator::CONTAINS, |
1453
|
|
|
1174643 |
1454
|
|
|
), |
1455
|
|
|
'limit' => 10, |
1456
|
|
|
] |
1457
|
|
|
) |
1458
|
|
|
) |
1459
|
|
|
); |
1460
|
|
|
} |
1461
|
|
|
|
1462
|
|
View Code Duplication |
public function testFieldFilterBetween() |
1463
|
|
|
{ |
1464
|
|
|
$this->assertSearchResults( |
1465
|
|
|
[71, 73, 74], |
1466
|
|
|
$this->getContentSearchHandler()->findLocations( |
1467
|
|
|
new LocationQuery( |
1468
|
|
|
[ |
1469
|
|
|
'filter' => new Criterion\Field( |
1470
|
|
|
'price', |
1471
|
|
|
Criterion\Operator::BETWEEN, |
1472
|
|
|
[10000, 1000000] |
1473
|
|
|
), |
1474
|
|
|
'limit' => 10, |
1475
|
|
|
] |
1476
|
|
|
) |
1477
|
|
|
) |
1478
|
|
|
); |
1479
|
|
|
} |
1480
|
|
|
|
1481
|
|
View Code Duplication |
public function testFieldFilterOr() |
1482
|
|
|
{ |
1483
|
|
|
$this->assertSearchResults( |
1484
|
|
|
[12, 71, 73, 74], |
1485
|
|
|
$this->getContentSearchHandler()->findLocations( |
1486
|
|
|
new LocationQuery( |
1487
|
|
|
[ |
1488
|
|
|
'filter' => new Criterion\LogicalOr( |
1489
|
|
|
[ |
1490
|
|
|
new Criterion\Field( |
1491
|
|
|
'name', |
1492
|
|
|
Criterion\Operator::EQ, |
1493
|
|
|
'members' |
1494
|
|
|
), |
1495
|
|
|
new Criterion\Field( |
1496
|
|
|
'price', |
1497
|
|
|
Criterion\Operator::BETWEEN, |
1498
|
|
|
[10000, 1000000] |
1499
|
|
|
), |
1500
|
|
|
] |
1501
|
|
|
), |
1502
|
|
|
'limit' => 10, |
1503
|
|
|
] |
1504
|
|
|
) |
1505
|
|
|
) |
1506
|
|
|
); |
1507
|
|
|
} |
1508
|
|
|
|
1509
|
|
View Code Duplication |
public function testIsMainLocationFilter() |
1510
|
|
|
{ |
1511
|
|
|
$this->assertSearchResults( |
1512
|
|
|
[225], |
1513
|
|
|
$this->getContentSearchHandler()->findLocations( |
1514
|
|
|
new LocationQuery( |
1515
|
|
|
[ |
1516
|
|
|
'filter' => new Criterion\LogicalAnd( |
1517
|
|
|
[ |
1518
|
|
|
new Criterion\ParentLocationId(224), |
1519
|
|
|
new Criterion\Location\IsMainLocation( |
1520
|
|
|
Criterion\Location\IsMainLocation::MAIN |
1521
|
|
|
), |
1522
|
|
|
] |
1523
|
|
|
), |
1524
|
|
|
'limit' => 10, |
1525
|
|
|
] |
1526
|
|
|
) |
1527
|
|
|
) |
1528
|
|
|
); |
1529
|
|
|
} |
1530
|
|
|
|
1531
|
|
View Code Duplication |
public function testIsNotMainLocationFilter() |
1532
|
|
|
{ |
1533
|
|
|
$this->assertSearchResults( |
1534
|
|
|
[510], |
1535
|
|
|
$this->getContentSearchHandler()->findLocations( |
1536
|
|
|
new LocationQuery( |
1537
|
|
|
[ |
1538
|
|
|
'filter' => new Criterion\LogicalAnd( |
1539
|
|
|
[ |
1540
|
|
|
new Criterion\ParentLocationId(224), |
1541
|
|
|
new Criterion\Location\IsMainLocation( |
1542
|
|
|
Criterion\Location\IsMainLocation::NOT_MAIN |
1543
|
|
|
), |
1544
|
|
|
] |
1545
|
|
|
), |
1546
|
|
|
'limit' => 10, |
1547
|
|
|
] |
1548
|
|
|
) |
1549
|
|
|
) |
1550
|
|
|
); |
1551
|
|
|
} |
1552
|
|
|
} |
1553
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..