Code Duplication    Length = 27-35 lines in 2 locations

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

@@ 398-432 (lines=35) @@
395
     *
396
     * @return \eZ\Publish\API\Repository\Values\Content\Content Content Draft
397
     */
398
    protected function createContentDraft(
399
        $contentTypeIdentifier,
400
        $parentLocationId,
401
        array $fieldValues
402
    ) {
403
        $repository = $this->getRepository();
404
        $contentService = $repository->getContentService();
405
        $contentTypeService = $repository->getContentTypeService();
406
        $locationService = $repository->getLocationService();
407
408
        // Load content type
409
        $contentType = $contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
410
411
        // Prepare new Content Object
412
        $contentCreateStruct = $contentService->newContentCreateStruct($contentType, 'eng-US');
413
414
        foreach ($fieldValues as $fieldIdentifier => $fieldValue) {
415
            $contentCreateStruct->setField($fieldIdentifier, $fieldValue);
416
        }
417
418
        $contentCreateStruct->sectionId = $this->generateId('section', 1);
419
        $contentCreateStruct->alwaysAvailable = true;
420
421
        // Prepare Location
422
        $locationCreateStruct = $locationService->newLocationCreateStruct(
423
            $this->generateId('location', $parentLocationId)
424
        );
425
        // Create a draft
426
        $contentDraft = $contentService->createContent(
427
            $contentCreateStruct,
428
            [$locationCreateStruct]
429
        );
430
431
        return $contentDraft;
432
    }
433
}
434

eZ/Publish/API/Repository/Tests/SearchService/DeleteTranslationTest.php 1 location

@@ 33-59 (lines=27) @@
30
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
31
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
32
     */
33
    protected function createTestContentWithLanguages(array $languages): Content
34
    {
35
        $repository = $this->getRepository();
36
        $contentTypeService = $repository->getContentTypeService();
37
        $contentService = $repository->getContentService();
38
        $locationService = $repository->getLocationService();
39
40
        $contentTypeArticle = $contentTypeService->loadContentTypeByIdentifier('article');
41
        $contentCreateStructArticle = $contentService->newContentCreateStruct(
42
            $contentTypeArticle,
43
            'eng-GB'
44
        );
45
46
        foreach ($languages as $langCode => $title) {
47
            $contentCreateStructArticle->setField('title', $title, $langCode);
48
        }
49
50
        $locationCreateStructArticle = $locationService->newLocationCreateStruct(2);
51
        $draftArticle = $contentService->createContent(
52
            $contentCreateStructArticle,
53
            [$locationCreateStructArticle]
54
        );
55
        $content = $contentService->publishVersion($draftArticle->getVersionInfo());
56
        $this->refreshSearch($repository);
57
58
        return $content;
59
    }
60
61
    /**
62
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException