Code Duplication    Length = 16-23 lines in 3 locations

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

@@ 961-976 (lines=16) @@
958
     *
959
     * @return \eZ\Publish\API\Repository\Values\Content\Content
960
     */
961
    protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId)
962
    {
963
        $contentService = $repository->getContentService();
964
        $locationService = $repository->getLocationService();
965
        $contentTypeService = $repository->getContentTypeService();
966
967
        $contentType = $contentTypeService->loadContentTypeByIdentifier('forum');
968
        $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US');
969
        $newContent->setField('name', 'Media');
970
971
        $location = $locationService->newLocationCreateStruct($parentLocationId);
972
973
        $draftContent = $contentService->createContent($newContent, [$location]);
974
975
        return $contentService->publishVersion($draftContent->versionInfo);
976
    }
977
978
    /**
979
     * @param URLAliasService $urlAliasService

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

@@ 913-935 (lines=23) @@
910
     * @see \eZ\Publish\API\Repository\LocationService::loadLocations()
911
     * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations
912
     */
913
    public function testLoadLocationsThrowsBadStateException()
914
    {
915
        $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class);
916
917
        $repository = $this->getRepository();
918
919
        /* BEGIN: Use Case */
920
        $contentTypeService = $repository->getContentTypeService();
921
        $contentService = $repository->getContentService();
922
        $locationService = $repository->getLocationService();
923
924
        // Create new content, which is not published
925
        $folderType = $contentTypeService->loadContentTypeByIdentifier('folder');
926
        $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US');
927
        $contentCreate->setField('name', 'New Folder');
928
        $content = $contentService->createContent($contentCreate);
929
930
        // Throws Exception, since $content has no published version, yet
931
        $locationService->loadLocations(
932
            $content->contentInfo
933
        );
934
        /* END: Use Case */
935
    }
936
937
    /**
938
     * Test for the loadLocations() method.
@@ 3051-3072 (lines=22) @@
3048
     *
3049
     * @return \eZ\Publish\API\Repository\Values\Content\Content published Content
3050
     */
3051
    private function publishContentWithParentLocation($contentName, $parentLocationId)
3052
    {
3053
        $repository = $this->getRepository(false);
3054
        $locationService = $repository->getLocationService();
3055
3056
        $contentService = $repository->getContentService();
3057
        $contentTypeService = $repository->getContentTypeService();
3058
3059
        $contentCreateStruct = $contentService->newContentCreateStruct(
3060
            $contentTypeService->loadContentTypeByIdentifier('folder'),
3061
            'eng-US'
3062
        );
3063
        $contentCreateStruct->setField('name', $contentName);
3064
        $contentDraft = $contentService->createContent(
3065
            $contentCreateStruct,
3066
            [
3067
                $locationService->newLocationCreateStruct($parentLocationId),
3068
            ]
3069
        );
3070
3071
        return $contentService->publishVersion($contentDraft->versionInfo);
3072
    }
3073
3074
    /**
3075
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException