Code Duplication    Length = 36-36 lines in 2 locations

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

@@ 1742-1777 (lines=36) @@
1739
    /**
1740
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
1741
     */
1742
    protected function createTestContentType()
1743
    {
1744
        $repository = $this->getRepository();
1745
        $contentTypeService = $repository->getContentTypeService();
1746
1747
        $createStruct = $contentTypeService->newContentTypeCreateStruct('test-type');
1748
        $createStruct->mainLanguageCode = 'eng-GB';
1749
        $createStruct->names = ['eng-GB' => 'Test type'];
1750
        $createStruct->creatorId = 14;
1751
        $createStruct->creationDate = new \DateTime();
1752
1753
        $translatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer', 'ezinteger');
1754
        $translatableFieldCreate->names = ['eng-GB' => 'Simple translatable integer field'];
1755
        $translatableFieldCreate->fieldGroup = 'main';
1756
        $translatableFieldCreate->position = 1;
1757
        $translatableFieldCreate->isTranslatable = true;
1758
        $translatableFieldCreate->isSearchable = true;
1759
1760
        $createStruct->addFieldDefinition($translatableFieldCreate);
1761
1762
        $nonTranslatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer2', 'ezinteger');
1763
        $nonTranslatableFieldCreate->names = ['eng-GB' => 'Simple non-translatable integer field'];
1764
        $nonTranslatableFieldCreate->fieldGroup = 'main';
1765
        $nonTranslatableFieldCreate->position = 2;
1766
        $nonTranslatableFieldCreate->isTranslatable = false;
1767
        $nonTranslatableFieldCreate->isSearchable = true;
1768
1769
        $createStruct->addFieldDefinition($nonTranslatableFieldCreate);
1770
1771
        $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content');
1772
        $contentTypeDraft = $contentTypeService->createContentType($createStruct, [$contentGroup]);
1773
        $contentTypeService->publishContentTypeDraft($contentTypeDraft);
1774
        $contentType = $contentTypeService->loadContentType($contentTypeDraft->id);
1775
1776
        return $contentType;
1777
    }
1778
1779
    /**
1780
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType

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

@@ 50-85 (lines=36) @@
47
    /**
48
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
49
     */
50
    protected function createTestContentType()
51
    {
52
        $repository = $this->getRepository();
53
        $contentTypeService = $repository->getContentTypeService();
54
55
        $createStruct = $contentTypeService->newContentTypeCreateStruct('test-type');
56
        $createStruct->mainLanguageCode = 'eng-GB';
57
        $createStruct->names = ['eng-GB' => 'Test type'];
58
        $createStruct->creatorId = 14;
59
        $createStruct->creationDate = new DateTime();
60
61
        $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('search_field', 'ezinteger');
62
        $fieldCreate->names = ['eng-GB' => 'Search field'];
63
        $fieldCreate->fieldGroup = 'main';
64
        $fieldCreate->position = 1;
65
        $fieldCreate->isTranslatable = true;
66
        $fieldCreate->isSearchable = true;
67
68
        $createStruct->addFieldDefinition($fieldCreate);
69
70
        $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('sort_field', 'ezinteger');
71
        $fieldCreate->names = ['eng-GB' => 'Sort field'];
72
        $fieldCreate->fieldGroup = 'main';
73
        $fieldCreate->position = 2;
74
        $fieldCreate->isTranslatable = false;
75
        $fieldCreate->isSearchable = true;
76
77
        $createStruct->addFieldDefinition($fieldCreate);
78
79
        $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content');
80
        $contentTypeDraft = $contentTypeService->createContentType($createStruct, [$contentGroup]);
81
        $contentTypeService->publishContentTypeDraft($contentTypeDraft);
82
        $contentType = $contentTypeService->loadContentType($contentTypeDraft->id);
83
84
        return $contentType;
85
    }
86
87
    /**
88
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType