Completed
Push — master ( 727c99...0dc4f6 )
by André
21:06
created

HandlerContentTest   F

Complexity

Total Complexity 71

Size/Duplication

Total Lines 1419
Duplicated Lines 32.42 %

Coupling/Cohesion

Components 1
Dependencies 68

Importance

Changes 0
Metric Value
dl 460
loc 1419
c 0
b 0
f 0
rs 1.52
wmc 71
lcom 1
cbo 68

68 Methods

Rating   Name   Duplication   Size   Complexity  
B getContentSearchHandler() 0 149 1
A getContentMapperMock() 0 33 3
A getContentFieldHandlerMock() 0 7 1
A testFindWithoutOffsetLimit() 0 17 1
A testFindWithZeroLimit() 0 23 1
A testFindWithNullLimit() 23 23 1
A testFindWithOffsetToNonexistent() 23 23 1
A testFindSingle() 0 8 1
A testFindSingleWithNonSearchableField() 0 11 1
A testFindContentWithNonSearchableField() 16 16 1
A testFindSingleTooMany() 0 5 1
A testFindSingleZero() 0 5 1
A testContentIdFilter() 0 16 1
A testContentIdFilterCount() 0 17 1
A testContentAndCombinatorFilter() 0 23 1
A testContentOrCombinatorFilter() 0 35 2
A testContentNotCombinatorFilter() 0 25 1
A testContentSubtreeFilterIn() 16 16 1
A testContentSubtreeFilterEq() 14 14 1
A testContentTypeIdFilter() 14 14 1
A testContentTypeIdentifierFilter() 0 15 1
A testContentTypeGroupFilter() 14 14 1
A testDateMetadataFilterModifiedGreater() 0 18 1
A testDateMetadataFilterModifiedGreaterOrEqual() 0 18 1
A testDateMetadataFilterModifiedIn() 0 18 1
A testDateMetadataFilterModifiedBetween() 0 18 1
A testDateMetadataFilterCreatedBetween() 0 18 1
A testLocationIdFilter() 0 14 1
A testParentLocationIdFilter() 0 14 1
A testRemoteIdFilter() 0 16 1
A testLocationRemoteIdFilter() 0 16 1
A testSectionFilter() 14 14 1
A testStatusFilter() 0 25 1
A testFieldFilter() 0 18 1
A testFieldFilterIn() 0 18 1
A testFieldFilterContainsPartial() 0 18 1
A testFieldFilterContainsSimple() 0 18 1
A testFieldFilterContainsSimpleNoMatch() 0 18 1
A testFieldFilterBetween() 0 18 1
A testFieldFilterOr() 27 27 1
A testFullTextFilter() 14 14 1
A testFullTextWildcardFilter() 14 14 1
A testFullTextDisabledWildcardFilter() 16 16 1
A testFullTextFilterStopwordRemoval() 20 20 1
A testFullTextFilterNoStopwordRemoval() 31 31 1
A testFullTextFilterInvalidStopwordThreshold() 0 8 1
A testObjectStateIdFilter() 0 15 1
A testObjectStateIdFilterIn() 0 15 1
A testLanguageCodeFilter() 0 15 1
A testLanguageCodeFilterIn() 0 15 1
A testLanguageCodeFilterWithAlwaysAvailable() 15 15 1
A testVisibilityFilter() 0 17 1
A testUserMetadataFilterOwnerWrongUserId() 17 17 1
A testUserMetadataFilterOwnerAdministrator() 19 19 1
A testUserMetadataFilterOwnerEqAMember() 17 17 1
A testUserMetadataFilterOwnerInAMember() 17 17 1
A testUserMetadataFilterCreatorEqAMember() 17 17 1
A testUserMetadataFilterCreatorInAMember() 17 17 1
A testUserMetadataFilterEqGroupMember() 17 17 1
A testUserMetadataFilterInGroupMember() 17 17 1
A testUserMetadataFilterEqGroupMemberNoMatch() 17 17 1
A testUserMetadataFilterInGroupMemberNoMatch() 17 17 1
A testFieldRelationFilterContainsSingle() 0 17 1
A testFieldRelationFilterContainsSingleNoMatch() 17 17 1
A testFieldRelationFilterContainsArray() 0 17 1
A testFieldRelationFilterContainsArrayNotMatch() 0 17 1
A testFieldRelationFilterInArray() 0 17 1
A testFieldRelationFilterInArrayNotMatch() 0 17 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like HandlerContentTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use HandlerContentTest, and based on these observations, apply Extract Interface, too.

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;
12
use eZ\Publish\Core\Search\Legacy\Content;
13
use eZ\Publish\API\Repository\Values\Content\Query;
14
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
15
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
16
use eZ\Publish\SPI\Persistence\Content\ContentInfo;
17
use eZ\Publish\Core\Search\Legacy\Content\Location\Gateway as LocationGateway;
18
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper as LocationMapper;
19
use eZ\Publish\Core\Persistence\Legacy\Content\Mapper as ContentMapper;
20
use eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler;
21
22
/**
23
 * Content Search test case for ContentSearchHandler.
24
 */
25
class HandlerContentTest extends AbstractTestCase
26
{
27
    /**
28
     * Returns the content search handler to test.
29
     *
30
     * This method returns a fully functional search handler to perform tests
31
     * on.
32
     *
33
     * @param array $fullTextSearchConfiguration
34
     *
35
     * @return \eZ\Publish\Core\Search\Legacy\Content\Handler
36
     */
37
    protected function getContentSearchHandler(array $fullTextSearchConfiguration = array())
38
    {
39
        $transformationProcessor = new Persistence\TransformationProcessor\DefinitionBased(
40
            new Persistence\TransformationProcessor\DefinitionBased\Parser(),
41
            new Persistence\TransformationProcessor\PcreCompiler(
42
                new Persistence\Utf8Converter()
43
            ),
44
            glob(__DIR__ . '/../../../../Persistence/Tests/TransformationProcessor/_fixtures/transformations/*.tr')
45
        );
46
        $commaSeparatedCollectionValueHandler = new Content\Common\Gateway\CriterionHandler\FieldValue\Handler\Collection(
47
            $this->getDatabaseHandler(),
48
            $transformationProcessor,
49
            ','
50
        );
51
        $hyphenSeparatedCollectionValueHandler = new Content\Common\Gateway\CriterionHandler\FieldValue\Handler\Collection(
52
            $this->getDatabaseHandler(),
53
            $transformationProcessor,
54
            '-'
55
        );
56
        $simpleValueHandler = new Content\Common\Gateway\CriterionHandler\FieldValue\Handler\Simple(
57
            $this->getDatabaseHandler(),
58
            $transformationProcessor
59
        );
60
        $compositeValueHandler = new Content\Common\Gateway\CriterionHandler\FieldValue\Handler\Composite(
61
            $this->getDatabaseHandler(),
62
            $transformationProcessor
63
        );
64
65
        return new Content\Handler(
66
            new Content\Gateway\DoctrineDatabase(
67
                $this->getDatabaseHandler(),
68
                new Content\Common\Gateway\CriteriaConverter(
69
                    array(
70
                        new Content\Common\Gateway\CriterionHandler\ContentId(
71
                            $this->getDatabaseHandler()
72
                        ),
73
                        new Content\Common\Gateway\CriterionHandler\LogicalNot(
74
                            $this->getDatabaseHandler()
75
                        ),
76
                        new Content\Common\Gateway\CriterionHandler\LogicalAnd(
77
                            $this->getDatabaseHandler()
78
                        ),
79
                        new Content\Common\Gateway\CriterionHandler\LogicalOr(
80
                            $this->getDatabaseHandler()
81
                        ),
82
                        new Content\Gateway\CriterionHandler\Subtree(
83
                            $this->getDatabaseHandler()
84
                        ),
85
                        new Content\Common\Gateway\CriterionHandler\ContentTypeId(
86
                            $this->getDatabaseHandler()
87
                        ),
88
                        new Content\Common\Gateway\CriterionHandler\ContentTypeIdentifier(
89
                            $this->getDatabaseHandler(),
90
                            $this->getContentTypeHandler()
91
                        ),
92
                        new Content\Common\Gateway\CriterionHandler\ContentTypeGroupId(
93
                            $this->getDatabaseHandler()
94
                        ),
95
                        new Content\Common\Gateway\CriterionHandler\DateMetadata(
96
                            $this->getDatabaseHandler()
97
                        ),
98
                        new Content\Gateway\CriterionHandler\LocationId(
99
                            $this->getDatabaseHandler()
100
                        ),
101
                        new Content\Gateway\CriterionHandler\ParentLocationId(
102
                            $this->getDatabaseHandler()
103
                        ),
104
                        new Content\Common\Gateway\CriterionHandler\RemoteId(
105
                            $this->getDatabaseHandler()
106
                        ),
107
                        new Content\Gateway\CriterionHandler\LocationRemoteId(
108
                            $this->getDatabaseHandler()
109
                        ),
110
                        new Content\Common\Gateway\CriterionHandler\SectionId(
111
                            $this->getDatabaseHandler()
112
                        ),
113
                        new Content\Common\Gateway\CriterionHandler\FullText(
114
                            $this->getDatabaseHandler(),
115
                            $transformationProcessor,
116
                            $fullTextSearchConfiguration
117
                        ),
118
                        new Content\Common\Gateway\CriterionHandler\Field(
119
                            $this->getDatabaseHandler(),
120
                            $this->getContentTypeHandler(),
121
                            $this->getLanguageHandler(),
122
                            $this->getConverterRegistry(),
123
                            new Content\Common\Gateway\CriterionHandler\FieldValue\Converter(
124
                                new Content\Common\Gateway\CriterionHandler\FieldValue\HandlerRegistry(
125
                                    array(
126
                                        'ezboolean' => $simpleValueHandler,
127
                                        'ezcountry' => $commaSeparatedCollectionValueHandler,
128
                                        'ezdate' => $simpleValueHandler,
129
                                        'ezdatetime' => $simpleValueHandler,
130
                                        'ezemail' => $simpleValueHandler,
131
                                        'ezinteger' => $simpleValueHandler,
132
                                        'ezobjectrelation' => $simpleValueHandler,
133
                                        'ezobjectrelationlist' => $commaSeparatedCollectionValueHandler,
134
                                        'ezselection' => $hyphenSeparatedCollectionValueHandler,
135
                                        'eztime' => $simpleValueHandler,
136
                                    )
137
                                ),
138
                                $compositeValueHandler
139
                            ),
140
                            $transformationProcessor
141
                        ),
142
                        new Content\Common\Gateway\CriterionHandler\ObjectStateId(
143
                            $this->getDatabaseHandler()
144
                        ),
145
                        new Content\Common\Gateway\CriterionHandler\LanguageCode(
146
                            $this->getDatabaseHandler(),
147
                            $this->getLanguageMaskGenerator()
148
                        ),
149
                        new Content\Gateway\CriterionHandler\Visibility(
150
                            $this->getDatabaseHandler()
151
                        ),
152
                        new Content\Common\Gateway\CriterionHandler\MatchAll(
153
                            $this->getDatabaseHandler()
154
                        ),
155
                        new Content\Common\Gateway\CriterionHandler\UserMetadata(
156
                            $this->getDatabaseHandler()
157
                        ),
158
                        new Content\Common\Gateway\CriterionHandler\FieldRelation(
159
                            $this->getDatabaseHandler(),
160
                            $this->getContentTypeHandler(),
161
                            $this->getLanguageHandler()
162
                        ),
163
                    )
164
                ),
165
                new Content\Common\Gateway\SortClauseConverter(
166
                    array(
167
                        new Content\Common\Gateway\SortClauseHandler\ContentId($this->getDatabaseHandler()),
168
                    )
169
                ),
170
                $this->getLanguageHandler()
171
            ),
172
            $this->createMock(LocationGateway::class),
173
            new Content\WordIndexer\Gateway\DoctrineDatabase(
174
                $this->getDatabaseHandler(),
175
                $this->getContentTypeHandler(),
176
                $this->getDefinitionBasedTransformationProcessor(),
177
                new Content\WordIndexer\Repository\SearchIndex($this->getDatabaseHandler()),
178
                $this->getFullTextSearchConfiguration()
179
            ),
180
            $this->getContentMapperMock(),
181
            $this->createMock(LocationMapper::class),
182
            $this->getLanguageHandler(),
183
            $this->getFullTextMapper($this->getContentTypeHandler())
0 ignored issues
show
Compatibility introduced by
$this->getContentTypeHandler() of type object<eZ\Publish\SPI\Pe...e\Content\Type\Handler> is not a sub-type of object<eZ\Publish\Core\P...y\Content\Type\Handler>. It seems like you assume a concrete implementation of the interface eZ\Publish\SPI\Persistence\Content\Type\Handler to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
184
        );
185
    }
186
187
    /**
188
     * Returns a content mapper mock.
189
     *
190
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\Mapper
191
     */
192
    protected function getContentMapperMock()
193
    {
194
        $mapperMock = $this->getMockBuilder(ContentMapper::class)
195
            ->setConstructorArgs(
196
                array(
197
                    $this->getConverterRegistry(),
198
                    $this->getLanguageHandler(),
199
                )
200
            )
201
            ->setMethods(array('extractContentInfoFromRows'))
202
            ->getMock();
203
        $mapperMock->expects($this->any())
204
            ->method('extractContentInfoFromRows')
205
            ->with($this->isType('array'))
206
            ->will(
207
                $this->returnCallback(
208
                    function ($rows) {
209
                        $contentInfoObjs = array();
210
                        foreach ($rows as $row) {
211
                            $contentId = (int)$row['id'];
212
                            if (!isset($contentInfoObjs[$contentId])) {
213
                                $contentInfoObjs[$contentId] = new ContentInfo();
214
                                $contentInfoObjs[$contentId]->id = $contentId;
215
                            }
216
                        }
217
218
                        return array_values($contentInfoObjs);
219
                    }
220
                )
221
            );
222
223
        return $mapperMock;
224
    }
225
226
    /**
227
     * Returns a content field handler mock.
228
     *
229
     * @return \eZ\Publish\Core\Persistence\Legacy\Content\FieldHandler
230
     */
231
    protected function getContentFieldHandlerMock()
232
    {
233
        return $this->getMockBuilder(FieldHandler::class)
234
            ->disableOriginalConstructor()
235
            ->setMethods(array('loadExternalFieldData'))
236
            ->getMock();
237
    }
238
239
    /**
240
     * Bug #80.
241
     */
242
    public function testFindWithoutOffsetLimit()
243
    {
244
        $locator = $this->getContentSearchHandler();
245
246
        $result = $locator->findContent(
247
            new Query(
248
                array(
249
                    'filter' => new Criterion\ContentId(10),
250
                )
251
            )
252
        );
253
254
        $this->assertEquals(
255
            1,
256
            $result->totalCount
257
        );
258
    }
259
260
    /**
261
     * Bug #81, bug #82.
262
     */
263
    public function testFindWithZeroLimit()
264
    {
265
        $locator = $this->getContentSearchHandler();
266
267
        $result = $locator->findContent(
268
            new Query(
269
                array(
270
                    'filter' => new Criterion\ContentId(10),
271
                    'offset' => 0,
272
                    'limit' => 0,
273
                )
274
            )
275
        );
276
277
        $this->assertEquals(
278
            1,
279
            $result->totalCount
280
        );
281
        $this->assertEquals(
282
            array(),
283
            $result->searchHits
284
        );
285
    }
286
287
    /**
288
     * Issue with PHP_MAX_INT limit overflow in databases.
289
     */
290 View Code Duplication
    public function testFindWithNullLimit()
291
    {
292
        $locator = $this->getContentSearchHandler();
293
294
        $result = $locator->findContent(
295
            new Query(
296
                array(
297
                    'filter' => new Criterion\ContentId(10),
298
                    'offset' => 0,
299
                    'limit' => null,
300
                )
301
            )
302
        );
303
304
        $this->assertEquals(
305
            1,
306
            $result->totalCount
307
        );
308
        $this->assertEquals(
309
            1,
310
            count($result->searchHits)
311
        );
312
    }
313
314
    /**
315
     * Issue with offsetting to the nonexistent results produces \ezcQueryInvalidParameterException exception.
316
     */
317 View Code Duplication
    public function testFindWithOffsetToNonexistent()
318
    {
319
        $locator = $this->getContentSearchHandler();
320
321
        $result = $locator->findContent(
322
            new Query(
323
                array(
324
                    'filter' => new Criterion\ContentId(10),
325
                    'offset' => 1000,
326
                    'limit' => null,
327
                )
328
            )
329
        );
330
331
        $this->assertEquals(
332
            1,
333
            $result->totalCount
334
        );
335
        $this->assertEquals(
336
            0,
337
            count($result->searchHits)
338
        );
339
    }
340
341
    public function testFindSingle()
342
    {
343
        $locator = $this->getContentSearchHandler();
344
345
        $contentInfo = $locator->findSingle(new Criterion\ContentId(10));
346
347
        $this->assertEquals(10, $contentInfo->id);
348
    }
349
350
    /**
351
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
352
     */
353
    public function testFindSingleWithNonSearchableField()
354
    {
355
        $locator = $this->getContentSearchHandler();
356
        $locator->findSingle(
357
            new Criterion\Field(
358
                'tag_cloud_url',
359
                Criterion\Operator::EQ,
360
                'http://nimbus.com'
361
            )
362
        );
363
    }
364
365
    /**
366
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
367
     */
368 View Code Duplication
    public function testFindContentWithNonSearchableField()
369
    {
370
        $locator = $this->getContentSearchHandler();
371
        $locator->findContent(
372
            new Query(
373
                array(
374
                    'filter' => new Criterion\Field(
375
                        'tag_cloud_url',
376
                        Criterion\Operator::EQ,
377
                        'http://nimbus.com'
378
                    ),
379
                    'sortClauses' => array(new SortClause\ContentId()),
380
                )
381
            )
382
        );
383
    }
384
385
    /**
386
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
387
     */
388
    public function testFindSingleTooMany()
389
    {
390
        $locator = $this->getContentSearchHandler();
391
        $locator->findSingle(new Criterion\ContentId(array(4, 10, 12, 23)));
392
    }
393
394
    /**
395
     * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException
396
     */
397
    public function testFindSingleZero()
398
    {
399
        $locator = $this->getContentSearchHandler();
400
        $locator->findSingle(new Criterion\ContentId(0));
401
    }
402
403
    public function testContentIdFilter()
404
    {
405
        $this->assertSearchResults(
406
            array(4, 10),
407
            $this->getContentSearchHandler()->findContent(
408
                new Query(
409
                    array(
410
                        'filter' => new Criterion\ContentId(
411
                            array(1, 4, 10)
412
                        ),
413
                        'limit' => 10,
414
                    )
415
                )
416
            )
417
        );
418
    }
419
420
    public function testContentIdFilterCount()
421
    {
422
        $locator = $this->getContentSearchHandler();
423
424
        $result = $locator->findContent(
425
            new Query(
426
                array(
427
                    'filter' => new Criterion\ContentId(
428
                        array(1, 4, 10)
429
                    ),
430
                    'limit' => 10,
431
                )
432
            )
433
        );
434
435
        $this->assertSame(2, $result->totalCount);
436
    }
437
438
    public function testContentAndCombinatorFilter()
439
    {
440
        $this->assertSearchResults(
441
            array(4),
442
            $this->getContentSearchHandler()->findContent(
443
                new Query(
444
                    array(
445
                        'filter' => new Criterion\LogicalAnd(
446
                            array(
447
                                new Criterion\ContentId(
448
                                    array(1, 4, 10)
449
                                ),
450
                                new Criterion\ContentId(
451
                                    array(4, 12)
452
                                ),
453
                            )
454
                        ),
455
                        'limit' => 10,
456
                    )
457
                )
458
            )
459
        );
460
    }
461
462
    public function testContentOrCombinatorFilter()
463
    {
464
        $locator = $this->getContentSearchHandler();
465
466
        $result = $locator->findContent(
467
            new Query(
468
                array(
469
                    'filter' => new Criterion\LogicalOr(
470
                        array(
471
                            new Criterion\ContentId(
472
                                array(1, 4, 10)
473
                            ),
474
                            new Criterion\ContentId(
475
                                array(4, 12)
476
                            ),
477
                        )
478
                    ),
479
                    'limit' => 10,
480
                )
481
            )
482
        );
483
484
        $expectedContentIds = array(4, 10, 12);
485
486
        $this->assertEquals(
487
            count($expectedContentIds),
488
            count($result->searchHits)
489
        );
490
        foreach ($result->searchHits as $hit) {
491
            $this->assertContains(
492
                $hit->valueObject->id,
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<eZ\Publish\API\Re...ory\Values\ValueObject>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
493
                $expectedContentIds
494
            );
495
        }
496
    }
497
498
    public function testContentNotCombinatorFilter()
499
    {
500
        $this->assertSearchResults(
501
            array(4),
502
            $this->getContentSearchHandler()->findContent(
503
                new Query(
504
                    array(
505
                        'filter' => new Criterion\LogicalAnd(
506
                            array(
507
                                new Criterion\ContentId(
508
                                    array(1, 4, 10)
509
                                ),
510
                                new Criterion\LogicalNot(
511
                                    new Criterion\ContentId(
512
                                        array(10, 12)
513
                                    )
514
                                ),
515
                            )
516
                        ),
517
                        'limit' => 10,
518
                    )
519
                )
520
            )
521
        );
522
    }
523
524 View Code Duplication
    public function testContentSubtreeFilterIn()
525
    {
526
        $this->assertSearchResults(
527
            array(67, 68, 69, 70, 71, 72, 73, 74),
528
            $this->getContentSearchHandler()->findContent(
529
                new Query(
530
                    array(
531
                        'filter' => new Criterion\Subtree(
532
                            array('/1/2/69/')
533
                        ),
534
                        'limit' => 10,
535
                    )
536
                )
537
            )
538
        );
539
    }
540
541 View Code Duplication
    public function testContentSubtreeFilterEq()
542
    {
543
        $this->assertSearchResults(
544
            array(67, 68, 69, 70, 71, 72, 73, 74),
545
            $this->getContentSearchHandler()->findContent(
546
                new Query(
547
                    array(
548
                        'filter' => new Criterion\Subtree('/1/2/69/'),
549
                        'limit' => 10,
550
                    )
551
                )
552
            )
553
        );
554
    }
555
556 View Code Duplication
    public function testContentTypeIdFilter()
557
    {
558
        $this->assertSearchResults(
559
            array(10, 14, 226),
560
            $this->getContentSearchHandler()->findContent(
561
                new Query(
562
                    array(
563
                        'filter' => new Criterion\ContentTypeId(4),
564
                        'limit' => 10,
565
                    )
566
                )
567
            )
568
        );
569
    }
570
571
    public function testContentTypeIdentifierFilter()
572
    {
573
        $this->assertSearchResults(
574
            array(41, 45, 49, 50, 51),
575
            $this->getContentSearchHandler()->findContent(
576
                new Query(
577
                    array(
578
                        'filter' => new Criterion\ContentTypeIdentifier('folder'),
579
                        'limit' => 5,
580
                        'sortClauses' => array(new SortClause\ContentId()),
581
                    )
582
                )
583
            )
584
        );
585
    }
586
587 View Code Duplication
    public function testContentTypeGroupFilter()
588
    {
589
        $this->assertSearchResults(
590
            array(4, 10, 11, 12, 13, 14, 42, 225, 226),
591
            $this->getContentSearchHandler()->findContent(
592
                new Query(
593
                    array(
594
                        'filter' => new Criterion\ContentTypeGroupId(2),
595
                        'limit' => 10,
596
                    )
597
                )
598
            )
599
        );
600
    }
601
602
    public function testDateMetadataFilterModifiedGreater()
603
    {
604
        $this->assertSearchResults(
605
            array(11, 225, 226),
606
            $this->getContentSearchHandler()->findContent(
607
                new Query(
608
                    array(
609
                        'filter' => new Criterion\DateMetadata(
610
                            Criterion\DateMetadata::MODIFIED,
611
                            Criterion\Operator::GT,
612
                            1311154214
613
                        ),
614
                        'limit' => 10,
615
                    )
616
                )
617
            )
618
        );
619
    }
620
621
    public function testDateMetadataFilterModifiedGreaterOrEqual()
622
    {
623
        $this->assertSearchResults(
624
            array(11, 14, 225, 226),
625
            $this->getContentSearchHandler()->findContent(
626
                new Query(
627
                    array(
628
                        'filter' => new Criterion\DateMetadata(
629
                            Criterion\DateMetadata::MODIFIED,
630
                            Criterion\Operator::GTE,
631
                            1311154214
632
                        ),
633
                        'limit' => 10,
634
                    )
635
                )
636
            )
637
        );
638
    }
639
640
    public function testDateMetadataFilterModifiedIn()
641
    {
642
        $this->assertSearchResults(
643
            array(11, 14, 225, 226),
644
            $this->getContentSearchHandler()->findContent(
645
                new Query(
646
                    array(
647
                        'filter' => new Criterion\DateMetadata(
648
                            Criterion\DateMetadata::MODIFIED,
649
                            Criterion\Operator::IN,
650
                            array(1311154214, 1311154215)
651
                        ),
652
                        'limit' => 10,
653
                    )
654
                )
655
            )
656
        );
657
    }
658
659
    public function testDateMetadataFilterModifiedBetween()
660
    {
661
        $this->assertSearchResults(
662
            array(11, 14, 225, 226),
663
            $this->getContentSearchHandler()->findContent(
664
                new Query(
665
                    array(
666
                        'filter' => new Criterion\DateMetadata(
667
                            Criterion\DateMetadata::MODIFIED,
668
                            Criterion\Operator::BETWEEN,
669
                            array(1311154213, 1311154215)
670
                        ),
671
                        'limit' => 10,
672
                    )
673
                )
674
            )
675
        );
676
    }
677
678
    public function testDateMetadataFilterCreatedBetween()
679
    {
680
        $this->assertSearchResults(
681
            array(66, 131, 225),
682
            $this->getContentSearchHandler()->findContent(
683
                new Query(
684
                    array(
685
                        'filter' => new Criterion\DateMetadata(
686
                            Criterion\DateMetadata::CREATED,
687
                            Criterion\Operator::BETWEEN,
688
                            array(1299780749, 1311154215)
689
                        ),
690
                        'limit' => 10,
691
                    )
692
                )
693
            )
694
        );
695
    }
696
697
    public function testLocationIdFilter()
698
    {
699
        $this->assertSearchResults(
700
            array(4, 65),
701
            $this->getContentSearchHandler()->findContent(
702
                new Query(
703
                    array(
704
                        'filter' => new Criterion\LocationId(array(1, 2, 5)),
705
                        'limit' => 10,
706
                    )
707
                )
708
            )
709
        );
710
    }
711
712
    public function testParentLocationIdFilter()
713
    {
714
        $this->assertSearchResults(
715
            array(4, 41, 45, 56, 65),
716
            $this->getContentSearchHandler()->findContent(
717
                new Query(
718
                    array(
719
                        'filter' => new Criterion\ParentLocationId(array(1)),
720
                        'limit' => 10,
721
                    )
722
                )
723
            )
724
        );
725
    }
726
727
    public function testRemoteIdFilter()
728
    {
729
        $this->assertSearchResults(
730
            array(4, 10),
731
            $this->getContentSearchHandler()->findContent(
732
                new Query(
733
                    array(
734
                        'filter' => new Criterion\RemoteId(
735
                            array('f5c88a2209584891056f987fd965b0ba', 'faaeb9be3bd98ed09f606fc16d144eca')
736
                        ),
737
                        'limit' => 10,
738
                    )
739
                )
740
            )
741
        );
742
    }
743
744
    public function testLocationRemoteIdFilter()
745
    {
746
        $this->assertSearchResults(
747
            array(4, 65),
748
            $this->getContentSearchHandler()->findContent(
749
                new Query(
750
                    array(
751
                        'filter' => new Criterion\LocationRemoteId(
752
                            array('3f6d92f8044aed134f32153517850f5a', 'f3e90596361e31d496d4026eb624c983')
753
                        ),
754
                        'limit' => 10,
755
                    )
756
                )
757
            )
758
        );
759
    }
760
761 View Code Duplication
    public function testSectionFilter()
762
    {
763
        $this->assertSearchResults(
764
            array(4, 10, 11, 12, 13, 14, 42, 226),
765
            $this->getContentSearchHandler()->findContent(
766
                new Query(
767
                    array(
768
                        'filter' => new Criterion\SectionId(array(2)),
769
                        'limit' => 10,
770
                    )
771
                )
772
            )
773
        );
774
    }
775
776
    public function testStatusFilter()
777
    {
778
        $this->assertSearchResults(
779
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
780
            $searchResult = $this->getContentSearchHandler()->findContent(
781
                new Query(
782
                    array(
783
                        // Status criterion is gone, but this will also match all published
784
                        'filter' => new Criterion\LogicalNot(
785
                            new Criterion\ContentId(
786
                                array(0)
787
                            )
788
                        ),
789
                        'limit' => 10,
790
                        'sortClauses' => array(new SortClause\ContentId()),
791
                    )
792
                )
793
            )
794
        );
795
796
        $this->assertEquals(
797
            185,
798
            $searchResult->totalCount
799
        );
800
    }
801
802
    public function testFieldFilter()
803
    {
804
        $this->assertSearchResults(
805
            array(11),
806
            $this->getContentSearchHandler()->findContent(
807
                new Query(
808
                    array(
809
                        'filter' => new Criterion\Field(
810
                            'name',
811
                            Criterion\Operator::EQ,
812
                            'members'
813
                        ),
814
                        'limit' => 10,
815
                    )
816
                )
817
            )
818
        );
819
    }
820
821
    public function testFieldFilterIn()
822
    {
823
        $this->assertSearchResults(
824
            array(11, 42),
825
            $this->getContentSearchHandler()->findContent(
826
                new Query(
827
                    array(
828
                        'filter' => new Criterion\Field(
829
                            'name',
830
                            Criterion\Operator::IN,
831
                            array('members', 'anonymous users')
832
                        ),
833
                        'limit' => 10,
834
                    )
835
                )
836
            )
837
        );
838
    }
839
840
    public function testFieldFilterContainsPartial()
841
    {
842
        $this->assertSearchResults(
843
            array(42),
844
            $this->getContentSearchHandler()->findContent(
845
                new Query(
846
                    array(
847
                        'filter' => new Criterion\Field(
848
                            'name',
849
                            Criterion\Operator::CONTAINS,
850
                            'nonymous use'
851
                        ),
852
                        'limit' => 10,
853
                    )
854
                )
855
            )
856
        );
857
    }
858
859
    public function testFieldFilterContainsSimple()
860
    {
861
        $this->assertSearchResults(
862
            array(77),
863
            $this->getContentSearchHandler()->findContent(
864
                new Query(
865
                    array(
866
                        'filter' => new Criterion\Field(
867
                            'publish_date',
868
                            Criterion\Operator::CONTAINS,
869
                            1174643880
870
                        ),
871
                        'limit' => 10,
872
                    )
873
                )
874
            )
875
        );
876
    }
877
878
    public function testFieldFilterContainsSimpleNoMatch()
879
    {
880
        $this->assertSearchResults(
881
            array(),
882
            $this->getContentSearchHandler()->findContent(
883
                new Query(
884
                    array(
885
                        'filter' => new Criterion\Field(
886
                            'publish_date',
887
                            Criterion\Operator::CONTAINS,
888
                            1174643
889
                        ),
890
                        'limit' => 10,
891
                    )
892
                )
893
            )
894
        );
895
    }
896
897
    public function testFieldFilterBetween()
898
    {
899
        $this->assertSearchResults(
900
            array(69, 71, 72),
901
            $this->getContentSearchHandler()->findContent(
902
                new Query(
903
                    array(
904
                        'filter' => new Criterion\Field(
905
                            'price',
906
                            Criterion\Operator::BETWEEN,
907
                            array(10000, 1000000)
908
                        ),
909
                        'limit' => 10,
910
                    )
911
                )
912
            )
913
        );
914
    }
915
916 View Code Duplication
    public function testFieldFilterOr()
917
    {
918
        $this->assertSearchResults(
919
            array(11, 69, 71, 72),
920
            $this->getContentSearchHandler()->findContent(
921
                new Query(
922
                    array(
923
                        'filter' => new Criterion\LogicalOr(
924
                            array(
925
                                new Criterion\Field(
926
                                    'name',
927
                                    Criterion\Operator::EQ,
928
                                    'members'
929
                                ),
930
                                new Criterion\Field(
931
                                    'price',
932
                                    Criterion\Operator::BETWEEN,
933
                                    array(10000, 1000000)
934
                                ),
935
                            )
936
                        ),
937
                        'limit' => 10,
938
                    )
939
                )
940
            )
941
        );
942
    }
943
944 View Code Duplication
    public function testFullTextFilter()
945
    {
946
        $this->assertSearchResults(
947
            array(191),
948
            $this->getContentSearchHandler()->findContent(
949
                new Query(
950
                    array(
951
                        'filter' => new Criterion\FullText('applied webpage'),
952
                        'limit' => 10,
953
                    )
954
                )
955
            )
956
        );
957
    }
958
959 View Code Duplication
    public function testFullTextWildcardFilter()
960
    {
961
        $this->assertSearchResults(
962
            array(191),
963
            $this->getContentSearchHandler()->findContent(
964
                new Query(
965
                    array(
966
                        'filter' => new Criterion\FullText('applie*'),
967
                        'limit' => 10,
968
                    )
969
                )
970
            )
971
        );
972
    }
973
974 View Code Duplication
    public function testFullTextDisabledWildcardFilter()
975
    {
976
        $this->assertSearchResults(
977
            array(),
978
            $this->getContentSearchHandler(
979
                array('enableWildcards' => false)
980
            )->findContent(
981
                new Query(
982
                    array(
983
                        'filter' => new Criterion\FullText('applie*'),
984
                        'limit' => 10,
985
                    )
986
                )
987
            )
988
        );
989
    }
990
991 View Code Duplication
    public function testFullTextFilterStopwordRemoval()
992
    {
993
        $handler = $this->getContentSearchHandler(
994
            array(
995
                'stopWordThresholdFactor' => 0.1,
996
            )
997
        );
998
999
        $this->assertSearchResults(
1000
            array(),
1001
            $handler->findContent(
1002
                new Query(
1003
                    array(
1004
                        'filter' => new Criterion\FullText('the'),
1005
                        'limit' => 10,
1006
                    )
1007
                )
1008
            )
1009
        );
1010
    }
1011
1012 View Code Duplication
    public function testFullTextFilterNoStopwordRemoval()
1013
    {
1014
        $handler = $this->getContentSearchHandler(
1015
            array(
1016
                'stopWordThresholdFactor' => 1,
1017
            )
1018
        );
1019
1020
        $result = $handler->findContent(
1021
            new Query(
1022
                array(
1023
                    'filter' => new Criterion\FullText(
1024
                        'the'
1025
                    ),
1026
                    'limit' => 10,
1027
                )
1028
            )
1029
        );
1030
1031
        $this->assertEquals(
1032
            10,
1033
            count(
1034
                array_map(
1035
                    function ($hit) {
1036
                        return $hit->valueObject->id;
1037
                    },
1038
                    $result->searchHits
1039
                )
1040
            )
1041
        );
1042
    }
1043
1044
    /**
1045
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
1046
     */
1047
    public function testFullTextFilterInvalidStopwordThreshold()
1048
    {
1049
        $this->getContentSearchHandler(
1050
            array(
1051
                'stopWordThresholdFactor' => 2,
1052
            )
1053
        );
1054
    }
1055
1056
    public function testObjectStateIdFilter()
1057
    {
1058
        $this->assertSearchResults(
1059
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1060
            $this->getContentSearchHandler()->findContent(
1061
                new Query(
1062
                    array(
1063
                        'filter' => new Criterion\ObjectStateId(1),
1064
                        'limit' => 10,
1065
                        'sortClauses' => array(new SortClause\ContentId()),
1066
                    )
1067
                )
1068
            )
1069
        );
1070
    }
1071
1072
    public function testObjectStateIdFilterIn()
1073
    {
1074
        $this->assertSearchResults(
1075
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1076
            $this->getContentSearchHandler()->findContent(
1077
                new Query(
1078
                    array(
1079
                        'filter' => new Criterion\ObjectStateId(array(1, 2)),
1080
                        'limit' => 10,
1081
                        'sortClauses' => array(new SortClause\ContentId()),
1082
                    )
1083
                )
1084
            )
1085
        );
1086
    }
1087
1088
    public function testLanguageCodeFilter()
1089
    {
1090
        $this->assertSearchResults(
1091
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1092
            $this->getContentSearchHandler()->findContent(
1093
                new Query(
1094
                    array(
1095
                        'filter' => new Criterion\LanguageCode('eng-US'),
1096
                        'limit' => 10,
1097
                        'sortClauses' => array(new SortClause\ContentId()),
1098
                    )
1099
                )
1100
            )
1101
        );
1102
    }
1103
1104
    public function testLanguageCodeFilterIn()
1105
    {
1106
        $this->assertSearchResults(
1107
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1108
            $this->getContentSearchHandler()->findContent(
1109
                new Query(
1110
                    array(
1111
                        'filter' => new Criterion\LanguageCode(array('eng-US', 'eng-GB')),
1112
                        'limit' => 10,
1113
                        'sortClauses' => array(new SortClause\ContentId()),
1114
                    )
1115
                )
1116
            )
1117
        );
1118
    }
1119
1120 View Code Duplication
    public function testLanguageCodeFilterWithAlwaysAvailable()
1121
    {
1122
        $this->assertSearchResults(
1123
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49, 50, 51, 56, 57, 65, 68, 70, 74, 76, 80),
1124
            $this->getContentSearchHandler()->findContent(
1125
                new Query(
1126
                    array(
1127
                        'filter' => new Criterion\LanguageCode('eng-GB', true),
1128
                        'limit' => 20,
1129
                        'sortClauses' => array(new SortClause\ContentId()),
1130
                    )
1131
                )
1132
            )
1133
        );
1134
    }
1135
1136
    public function testVisibilityFilter()
1137
    {
1138
        $this->assertSearchResults(
1139
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1140
            $this->getContentSearchHandler()->findContent(
1141
                new Query(
1142
                    array(
1143
                        'filter' => new Criterion\Visibility(
1144
                            Criterion\Visibility::VISIBLE
1145
                        ),
1146
                        'limit' => 10,
1147
                        'sortClauses' => array(new SortClause\ContentId()),
1148
                    )
1149
                )
1150
            )
1151
        );
1152
    }
1153
1154 View Code Duplication
    public function testUserMetadataFilterOwnerWrongUserId()
1155
    {
1156
        $this->assertSearchResults(
1157
            array(),
1158
            $this->getContentSearchHandler()->findContent(
1159
                new Query(
1160
                    array(
1161
                        'filter' => new Criterion\UserMetadata(
1162
                            Criterion\UserMetadata::OWNER,
1163
                            Criterion\Operator::EQ,
1164
                            2
1165
                        ),
1166
                    )
1167
                )
1168
            )
1169
        );
1170
    }
1171
1172 View Code Duplication
    public function testUserMetadataFilterOwnerAdministrator()
1173
    {
1174
        $this->assertSearchResults(
1175
            array(4, 10, 11, 12, 13, 14, 41, 42, 45, 49),
1176
            $this->getContentSearchHandler()->findContent(
1177
                new Query(
1178
                    array(
1179
                        'filter' => new Criterion\UserMetadata(
1180
                            Criterion\UserMetadata::OWNER,
1181
                            Criterion\Operator::EQ,
1182
                            14
1183
                        ),
1184
                        'limit' => 10,
1185
                        'sortClauses' => array(new SortClause\ContentId()),
1186
                    )
1187
                )
1188
            )
1189
        );
1190
    }
1191
1192 View Code Duplication
    public function testUserMetadataFilterOwnerEqAMember()
1193
    {
1194
        $this->assertSearchResults(
1195
            array(223),
1196
            $this->getContentSearchHandler()->findContent(
1197
                new Query(
1198
                    array(
1199
                        'filter' => new Criterion\UserMetadata(
1200
                            Criterion\UserMetadata::OWNER,
1201
                            Criterion\Operator::EQ,
1202
                            226
1203
                        ),
1204
                    )
1205
                )
1206
            )
1207
        );
1208
    }
1209
1210 View Code Duplication
    public function testUserMetadataFilterOwnerInAMember()
1211
    {
1212
        $this->assertSearchResults(
1213
            array(223),
1214
            $this->getContentSearchHandler()->findContent(
1215
                new Query(
1216
                    array(
1217
                        'filter' => new Criterion\UserMetadata(
1218
                            Criterion\UserMetadata::OWNER,
1219
                            Criterion\Operator::IN,
1220
                            array(226)
1221
                        ),
1222
                    )
1223
                )
1224
            )
1225
        );
1226
    }
1227
1228 View Code Duplication
    public function testUserMetadataFilterCreatorEqAMember()
1229
    {
1230
        $this->assertSearchResults(
1231
            array(223),
1232
            $this->getContentSearchHandler()->findContent(
1233
                new Query(
1234
                    array(
1235
                        'filter' => new Criterion\UserMetadata(
1236
                            Criterion\UserMetadata::MODIFIER,
1237
                            Criterion\Operator::EQ,
1238
                            226
1239
                        ),
1240
                    )
1241
                )
1242
            )
1243
        );
1244
    }
1245
1246 View Code Duplication
    public function testUserMetadataFilterCreatorInAMember()
1247
    {
1248
        $this->assertSearchResults(
1249
            array(223),
1250
            $this->getContentSearchHandler()->findContent(
1251
                new Query(
1252
                    array(
1253
                        'filter' => new Criterion\UserMetadata(
1254
                            Criterion\UserMetadata::MODIFIER,
1255
                            Criterion\Operator::IN,
1256
                            array(226)
1257
                        ),
1258
                    )
1259
                )
1260
            )
1261
        );
1262
    }
1263
1264 View Code Duplication
    public function testUserMetadataFilterEqGroupMember()
1265
    {
1266
        $this->assertSearchResults(
1267
            array(223),
1268
            $this->getContentSearchHandler()->findContent(
1269
                new Query(
1270
                    array(
1271
                        'filter' => new Criterion\UserMetadata(
1272
                            Criterion\UserMetadata::GROUP,
1273
                            Criterion\Operator::EQ,
1274
                            11
1275
                        ),
1276
                    )
1277
                )
1278
            )
1279
        );
1280
    }
1281
1282 View Code Duplication
    public function testUserMetadataFilterInGroupMember()
1283
    {
1284
        $this->assertSearchResults(
1285
            array(223),
1286
            $this->getContentSearchHandler()->findContent(
1287
                new Query(
1288
                    array(
1289
                        'filter' => new Criterion\UserMetadata(
1290
                            Criterion\UserMetadata::GROUP,
1291
                            Criterion\Operator::IN,
1292
                            array(11)
1293
                        ),
1294
                    )
1295
                )
1296
            )
1297
        );
1298
    }
1299
1300 View Code Duplication
    public function testUserMetadataFilterEqGroupMemberNoMatch()
1301
    {
1302
        $this->assertSearchResults(
1303
            array(),
1304
            $this->getContentSearchHandler()->findContent(
1305
                new Query(
1306
                    array(
1307
                        'filter' => new Criterion\UserMetadata(
1308
                            Criterion\UserMetadata::GROUP,
1309
                            Criterion\Operator::EQ,
1310
                            13
1311
                        ),
1312
                    )
1313
                )
1314
            )
1315
        );
1316
    }
1317
1318 View Code Duplication
    public function testUserMetadataFilterInGroupMemberNoMatch()
1319
    {
1320
        $this->assertSearchResults(
1321
            array(),
1322
            $this->getContentSearchHandler()->findContent(
1323
                new Query(
1324
                    array(
1325
                        'filter' => new Criterion\UserMetadata(
1326
                            Criterion\UserMetadata::GROUP,
1327
                            Criterion\Operator::IN,
1328
                            array(13)
1329
                        ),
1330
                    )
1331
                )
1332
            )
1333
        );
1334
    }
1335
1336
    public function testFieldRelationFilterContainsSingle()
1337
    {
1338
        $this->assertSearchResults(
1339
            array(67),
1340
            $this->getContentSearchHandler()->findContent(
1341
                new Query(
1342
                    array(
1343
                        'filter' => new Criterion\FieldRelation(
1344
                            'billboard',
1345
                            Criterion\Operator::CONTAINS,
1346
                            array(60)
1347
                        ),
1348
                    )
1349
                )
1350
            )
1351
        );
1352
    }
1353
1354 View Code Duplication
    public function testFieldRelationFilterContainsSingleNoMatch()
1355
    {
1356
        $this->assertSearchResults(
1357
            array(),
1358
            $this->getContentSearchHandler()->findContent(
1359
                new Query(
1360
                    array(
1361
                        'filter' => new Criterion\FieldRelation(
1362
                            'billboard',
1363
                            Criterion\Operator::CONTAINS,
1364
                            array(4)
1365
                        ),
1366
                    )
1367
                )
1368
            )
1369
        );
1370
    }
1371
1372
    public function testFieldRelationFilterContainsArray()
1373
    {
1374
        $this->assertSearchResults(
1375
            array(67),
1376
            $this->getContentSearchHandler()->findContent(
1377
                new Query(
1378
                    array(
1379
                        'filter' => new Criterion\FieldRelation(
1380
                            'billboard',
1381
                            Criterion\Operator::CONTAINS,
1382
                            array(60, 75)
1383
                        ),
1384
                    )
1385
                )
1386
            )
1387
        );
1388
    }
1389
1390
    public function testFieldRelationFilterContainsArrayNotMatch()
1391
    {
1392
        $this->assertSearchResults(
1393
            array(),
1394
            $this->getContentSearchHandler()->findContent(
1395
                new Query(
1396
                    array(
1397
                        'filter' => new Criterion\FieldRelation(
1398
                            'billboard',
1399
                            Criterion\Operator::CONTAINS,
1400
                            array(60, 64)
1401
                        ),
1402
                    )
1403
                )
1404
            )
1405
        );
1406
    }
1407
1408
    public function testFieldRelationFilterInArray()
1409
    {
1410
        $this->assertSearchResults(
1411
            array(67, 75),
1412
            $this->getContentSearchHandler()->findContent(
1413
                new Query(
1414
                    array(
1415
                        'filter' => new Criterion\FieldRelation(
1416
                            'billboard',
1417
                            Criterion\Operator::IN,
1418
                            array(60, 64)
1419
                        ),
1420
                    )
1421
                )
1422
            )
1423
        );
1424
    }
1425
1426
    public function testFieldRelationFilterInArrayNotMatch()
1427
    {
1428
        $this->assertSearchResults(
1429
            array(),
1430
            $this->getContentSearchHandler()->findContent(
1431
                new Query(
1432
                    array(
1433
                        'filter' => new Criterion\FieldRelation(
1434
                            'billboard',
1435
                            Criterion\Operator::IN,
1436
                            array(4, 10)
1437
                        ),
1438
                    )
1439
                )
1440
            )
1441
        );
1442
    }
1443
}
1444