Code Duplication    Length = 36-36 lines in 2 locations

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

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

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

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