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