Code Duplication    Length = 16-22 lines in 3 locations

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

@@ 866-881 (lines=16) @@
863
     *
864
     * @return \eZ\Publish\API\Repository\Values\Content\Content
865
     */
866
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
867
    {
868
        $contentService = $repository->getContentService();
869
        $locationService = $repository->getLocationService();
870
        $contentTypeService = $repository->getContentTypeService();
871
872
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
873
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
874
        $newContent->setField('name', 'Media');
875
876
        $location = $locationService->newLocationCreateStruct($parentLocationId);
877
878
        $draftContent = $contentService->createContent($newContent, [$location]);
879
880
        return $contentService->publishVersion($draftContent->versionInfo);
881
    }
882
883
    /**
884
     * @param URLAliasService $urlAliasService

eZ/Publish/API/Repository/Tests/LocationServiceTest.php 2 locations

@@ 802-822 (lines=21) @@
799
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
800
     * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException
801
     */
802
    public function testLoadLocationsThrowsBadStateException()
803
    {
804
        $repository = $this->getRepository();
805
806
        /* BEGIN: Use Case */
807
        $contentTypeService = $repository->getContentTypeService();
808
        $contentService = $repository->getContentService();
809
        $locationService = $repository->getLocationService();
810
811
        // Create new content, which is not published
812
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
813
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
814
        $contentCreate->setField('name', 'New Folder');
815
        $content = $contentService->createContent($contentCreate);
816
817
        // Throws Exception, since $content has no published version, yet
818
        $locationService->loadLocations(
819
            $content->contentInfo
820
        );
821
        /* END: Use Case */
822
    }
823
824
    /**
825
     * Test for the loadLocations() method.
@@ 2775-2796 (lines=22) @@
2772
     *
2773
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
2774
     */
2775
    private function publishContentWithParentLocation($contentName, $parentLocationId)
2776
    {
2777
        $repository = $this->getRepository(false);
2778
        $locationService = $repository->getLocationService();
2779
2780
        $contentService = $repository->getContentService();
2781
        $contentTypeService = $repository->getContentTypeService();
2782
2783
        $contentCreateStruct = $contentService->newContentCreateStruct(
2784
            $contentTypeService->loadContentTypeByIdentifier('folder'),
2785
            'eng-US'
2786
        );
2787
        $contentCreateStruct->setField('name', $contentName);
2788
        $contentDraft = $contentService->createContent(
2789
            $contentCreateStruct,
2790
            [
2791
                $locationService->newLocationCreateStruct($parentLocationId),
2792
            ]
2793
        );
2794
2795
        return $contentService->publishVersion($contentDraft->versionInfo);
2796
    }
2797
}
2798