| @@ 930-945 (lines=16) @@ | ||
| 927 | * |
|
| 928 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 929 | */ |
|
| 930 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 931 | { |
|
| 932 | $contentService = $repository->getContentService(); |
|
| 933 | $locationService = $repository->getLocationService(); |
|
| 934 | $contentTypeService = $repository->getContentTypeService(); |
|
| 935 | ||
| 936 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 937 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 938 | $newContent->setField('name', 'Media'); |
|
| 939 | ||
| 940 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 941 | ||
| 942 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 943 | ||
| 944 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 945 | } |
|
| 946 | ||
| 947 | /** |
|
| 948 | * @param URLAliasService $urlAliasService |
|
| @@ 848-870 (lines=23) @@ | ||
| 845 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
|
| 846 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 847 | */ |
|
| 848 | public function testLoadLocationsThrowsBadStateException() |
|
| 849 | { |
|
| 850 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class); |
|
| 851 | ||
| 852 | $repository = $this->getRepository(); |
|
| 853 | ||
| 854 | /* BEGIN: Use Case */ |
|
| 855 | $contentTypeService = $repository->getContentTypeService(); |
|
| 856 | $contentService = $repository->getContentService(); |
|
| 857 | $locationService = $repository->getLocationService(); |
|
| 858 | ||
| 859 | // Create new content, which is not published |
|
| 860 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 861 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 862 | $contentCreate->setField('name', 'New Folder'); |
|
| 863 | $content = $contentService->createContent($contentCreate); |
|
| 864 | ||
| 865 | // Throws Exception, since $content has no published version, yet |
|
| 866 | $locationService->loadLocations( |
|
| 867 | $content->contentInfo |
|
| 868 | ); |
|
| 869 | /* END: Use Case */ |
|
| 870 | } |
|
| 871 | ||
| 872 | /** |
|
| 873 | * Test for the loadLocations() method. |
|
| @@ 2918-2939 (lines=22) @@ | ||
| 2915 | * |
|
| 2916 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2917 | */ |
|
| 2918 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2919 | { |
|
| 2920 | $repository = $this->getRepository(false); |
|
| 2921 | $locationService = $repository->getLocationService(); |
|
| 2922 | ||
| 2923 | $contentService = $repository->getContentService(); |
|
| 2924 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2925 | ||
| 2926 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2927 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2928 | 'eng-US' |
|
| 2929 | ); |
|
| 2930 | $contentCreateStruct->setField('name', $contentName); |
|
| 2931 | $contentDraft = $contentService->createContent( |
|
| 2932 | $contentCreateStruct, |
|
| 2933 | [ |
|
| 2934 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2935 | ] |
|
| 2936 | ); |
|
| 2937 | ||
| 2938 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2939 | } |
|
| 2940 | } |
|
| 2941 | ||