Code Duplication    Length = 13-19 lines in 5 locations

eZ/Publish/API/Repository/Tests/SearchEngineIndexingTest.php 2 locations

@@ 97-114 (lines=18) @@
94
     *
95
     * @depends testFindContentInfoFullTextIsSearchable
96
     */
97
    public function testFindContentInfoFullTextIsNotSearchable()
98
    {
99
        $searchTerm = 'pamplemousse';
100
        $this->createFullTextIsSearchableContent($searchTerm, false);
101
102
        $repository = $this->getRepository();
103
        $searchService = $repository->getSearchService();
104
105
        $query = new Query(
106
            [
107
                'query' => new Criterion\FullText($searchTerm),
108
            ]
109
        );
110
111
        $searchResult = $searchService->findContentInfo($query);
112
113
        $this->assertEquals(0, $searchResult->totalCount);
114
    }
115
116
    /**
117
     * Test that indexing full text data depends on the isSearchable flag on the field definition.
@@ 121-137 (lines=17) @@
118
     *
119
     * @depends testFindLocationsFullTextIsSearchable
120
     */
121
    public function testFindLocationsFullTextIsNotSearchable()
122
    {
123
        $searchTerm = 'pamplemousse';
124
125
        $repository = $this->getRepository(false);
126
        $searchService = $repository->getSearchService();
127
128
        $query = new LocationQuery(
129
            [
130
                'query' => new Criterion\FullText($searchTerm),
131
            ]
132
        );
133
134
        $searchResult = $searchService->findLocations($query);
135
136
        $this->assertEquals(0, $searchResult->totalCount);
137
    }
138
139
    /**
140
     * Creates Content for testing full text search depending on the isSearchable flag.

eZ/Publish/API/Repository/Tests/FieldType/KeywordIntegrationTest.php 1 location

@@ 597-609 (lines=13) @@
594
     *
595
     * @see \eZ\Publish\API\Repository\SearchService::findContent()
596
     */
597
    public function testFindContentFieldCriterion()
598
    {
599
        $this->createKeywordContent();
600
        $repository = $this->getRepository();
601
602
        $criterion = new Criterion\Field('tags', Criterion\Operator::IN, ['foo']);
603
        $query = new Query(['query' => $criterion]);
604
605
        $searchService = $repository->getSearchService();
606
        $searchResult = $searchService->findContent($query);
607
608
        $this->assertEquals(1, $searchResult->totalCount);
609
    }
610
}
611

eZ/Publish/API/Repository/Tests/SearchServiceLocationTest.php 1 location

@@ 281-299 (lines=19) @@
278
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
279
     * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains
280
     */
281
    public function testFieldCollectionContainsNoMatch()
282
    {
283
        $this->createMultipleCountriesContent();
284
        $query = new LocationQuery(
285
            [
286
                'query' => new Criterion\Field(
287
                    'countries',
288
                    Criterion\Operator::CONTAINS,
289
                    'Netherlands Antilles'
290
                ),
291
            ]
292
        );
293
294
        $repository = $this->getRepository();
295
        $searchService = $repository->getSearchService();
296
        $result = $searchService->findLocations($query);
297
298
        $this->assertEquals(0, $result->totalCount);
299
    }
300
301
    /**
302
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException

eZ/Publish/API/Repository/Tests/SearchServiceTest.php 1 location

@@ 1388-1406 (lines=19) @@
1385
     * @see \eZ\Publish\API\Repository\SearchService::findContent()
1386
     * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains
1387
     */
1388
    public function testFieldCollectionContainsNoMatch()
1389
    {
1390
        $this->createMultipleCountriesContent();
1391
        $query = new Query(
1392
            [
1393
                'query' => new Criterion\Field(
1394
                    'countries',
1395
                    Criterion\Operator::CONTAINS,
1396
                    'Netherlands Antilles'
1397
                ),
1398
            ]
1399
        );
1400
1401
        $repository = $this->getRepository();
1402
        $searchService = $repository->getSearchService();
1403
        $result = $searchService->findContent($query);
1404
1405
        $this->assertEquals(0, $result->totalCount);
1406
    }
1407
1408
    /**
1409
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException