Code Duplication    Length = 23-24 lines in 4 locations

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

@@ 219-242 (lines=24) @@
216
     *
217
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
218
     */
219
    public function testFieldIsNotEmptyInLocation()
220
    {
221
        $testContents = $this->createMovieContent();
222
223
        $query = new LocationQuery(
224
            [
225
                'query' => new Criterion\IsFieldEmpty(
226
                    'subtitle',
227
                    false
228
                ),
229
            ]
230
        );
231
232
        $repository = $this->getRepository();
233
        $searchService = $repository->getSearchService();
234
        $result = $searchService->findLocations($query);
235
236
        $this->assertEquals(1, $result->totalCount);
237
238
        $this->assertEquals(
239
            $testContents[2]->contentInfo->mainLocationId,
240
            $result->searchHits[0]->valueObject->id
241
        );
242
    }
243
244
    /**
245
     * Test for the findLocations() method.
@@ 249-272 (lines=24) @@
246
     *
247
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
248
     */
249
    public function testFieldCollectionContains()
250
    {
251
        $testContent = $this->createMultipleCountriesContent();
252
253
        $query = new LocationQuery(
254
            [
255
                'query' => new Criterion\Field(
256
                    'countries',
257
                    Criterion\Operator::CONTAINS,
258
                    'Belgium'
259
                ),
260
            ]
261
        );
262
263
        $repository = $this->getRepository();
264
        $searchService = $repository->getSearchService();
265
        $result = $searchService->findLocations($query);
266
267
        $this->assertEquals(1, $result->totalCount);
268
        $this->assertEquals(
269
            $testContent->contentInfo->mainLocationId,
270
            $result->searchHits[0]->valueObject->id
271
        );
272
    }
273
274
    /**
275
     * Test for the findLocations() method.

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

@@ 1294-1316 (lines=23) @@
1291
     *
1292
     * @see \eZ\Publish\API\Repository\SearchService::findContent()
1293
     */
1294
    public function testFieldIsNotEmpty()
1295
    {
1296
        $testContents = $this->createMovieContent();
1297
1298
        $query = new Query(
1299
            [
1300
                'query' => new Criterion\IsFieldEmpty(
1301
                    'subtitle',
1302
                    false
1303
                ),
1304
            ]
1305
        );
1306
1307
        $repository = $this->getRepository();
1308
        $searchService = $repository->getSearchService();
1309
        $result = $searchService->findContent($query, ['eng-GB']);
1310
1311
        $this->assertEquals(1, $result->totalCount);
1312
        $this->assertEquals(
1313
            $testContents[2]->id,
1314
            $result->searchHits[0]->valueObject->id
1315
        );
1316
    }
1317
1318
    /**
1319
     * Test for the findContent() method.
@@ 1323-1346 (lines=24) @@
1320
     *
1321
     * @see \eZ\Publish\API\Repository\SearchService::findContent()
1322
     */
1323
    public function testFieldCollectionContains()
1324
    {
1325
        $testContent = $this->createMultipleCountriesContent();
1326
1327
        $query = new Query(
1328
            [
1329
                'query' => new Criterion\Field(
1330
                    'countries',
1331
                    Criterion\Operator::CONTAINS,
1332
                    'Belgium'
1333
                ),
1334
            ]
1335
        );
1336
1337
        $repository = $this->getRepository();
1338
        $searchService = $repository->getSearchService();
1339
        $result = $searchService->findContent($query);
1340
1341
        $this->assertEquals(1, $result->totalCount);
1342
        $this->assertEquals(
1343
            $testContent->id,
1344
            $result->searchHits[0]->valueObject->id
1345
        );
1346
    }
1347
1348
    /**
1349
     * Test for the findContent() method.