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