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 = ['eng-GB' => 'Test type'];
56
        $createStruct->creatorId = 14;
57
        $createStruct->creationDate = new DateTime();
58
59
        $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('search_field', 'ezinteger');
60
        $fieldCreate->names = ['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 = ['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, [$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

@@ 1606-1641 (lines=36) @@
1603
    /**
1604
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
1605
     */
1606
    protected function createTestContentType()
1607
    {
1608
        $repository = $this->getRepository();
1609
        $contentTypeService = $repository->getContentTypeService();
1610
1611
        $createStruct = $contentTypeService->newContentTypeCreateStruct('test-type');
1612
        $createStruct->mainLanguageCode = 'eng-GB';
1613
        $createStruct->names = ['eng-GB' => 'Test type'];
1614
        $createStruct->creatorId = 14;
1615
        $createStruct->creationDate = new \DateTime();
1616
1617
        $translatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer', 'ezinteger');
1618
        $translatableFieldCreate->names = ['eng-GB' => 'Simple translatable integer field'];
1619
        $translatableFieldCreate->fieldGroup = 'main';
1620
        $translatableFieldCreate->position = 1;
1621
        $translatableFieldCreate->isTranslatable = true;
1622
        $translatableFieldCreate->isSearchable = true;
1623
1624
        $createStruct->addFieldDefinition($translatableFieldCreate);
1625
1626
        $nonTranslatableFieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('integer2', 'ezinteger');
1627
        $nonTranslatableFieldCreate->names = ['eng-GB' => 'Simple non-translatable integer field'];
1628
        $nonTranslatableFieldCreate->fieldGroup = 'main';
1629
        $nonTranslatableFieldCreate->position = 2;
1630
        $nonTranslatableFieldCreate->isTranslatable = false;
1631
        $nonTranslatableFieldCreate->isSearchable = true;
1632
1633
        $createStruct->addFieldDefinition($nonTranslatableFieldCreate);
1634
1635
        $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content');
1636
        $contentTypeDraft = $contentTypeService->createContentType($createStruct, [$contentGroup]);
1637
        $contentTypeService->publishContentTypeDraft($contentTypeDraft);
1638
        $contentType = $contentTypeService->loadContentType($contentTypeDraft->id);
1639
1640
        return $contentType;
1641
    }
1642
1643
    /**
1644
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType