Code Duplication    Length = 36-36 lines in 2 locations

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

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

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

@@ 1671-1706 (lines=36) @@
1668
    /**
1669
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
1670
     */
1671
    protected function createTestContentType()
1672
    {
1673
        $repository = $this->getRepository();
1674
        $contentTypeService = $repository->getContentTypeService();
1675
1676
        $createStruct = $contentTypeService->newContentTypeCreateStruct('test-type');
1677
        $createStruct->mainLanguageCode = 'eng-GB';
1678
        $createStruct->names = array('eng-GB' => 'Test type');
1679
        $createStruct->creatorId = 14;
1680
        $createStruct->creationDate = new \DateTime();
1681
1682
        $translatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer', 'ezinteger');
1683
        $translatableFieldCreate->names = array('eng-GB' => 'Simple translatable integer field');
1684
        $translatableFieldCreate->fieldGroup = 'main';
1685
        $translatableFieldCreate->position = 1;
1686
        $translatableFieldCreate->isTranslatable = true;
1687
        $translatableFieldCreate->isSearchable = true;
1688
1689
        $createStruct->addFieldDefinition($translatableFieldCreate);
1690
1691
        $nonTranslatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer2', 'ezinteger');
1692
        $nonTranslatableFieldCreate->names = array('eng-GB' => 'Simple non-translatable integer field');
1693
        $nonTranslatableFieldCreate->fieldGroup = 'main';
1694
        $nonTranslatableFieldCreate->position = 2;
1695
        $nonTranslatableFieldCreate->isTranslatable = false;
1696
        $nonTranslatableFieldCreate->isSearchable = true;
1697
1698
        $createStruct->addFieldDefinition($nonTranslatableFieldCreate);
1699
1700
        $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content');
1701
        $contentTypeDraft = $contentTypeService->createContentType($createStruct, array($contentGroup));
1702
        $contentTypeService->publishContentTypeDraft($contentTypeDraft);
1703
        $contentType = $contentTypeService->loadContentType($contentTypeDraft->id);
1704
1705
        return $contentType;
1706
    }
1707
1708
    /**
1709
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType