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

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