| @@ 827-849 (lines=23) @@ | ||
| 824 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
|
| 825 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 826 | */ |
|
| 827 | public function testLoadLocationsThrowsBadStateException() |
|
| 828 | { |
|
| 829 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\BadStateException::class); |
|
| 830 | ||
| 831 | $repository = $this->getRepository(); |
|
| 832 | ||
| 833 | /* BEGIN: Use Case */ |
|
| 834 | $contentTypeService = $repository->getContentTypeService(); |
|
| 835 | $contentService = $repository->getContentService(); |
|
| 836 | $locationService = $repository->getLocationService(); |
|
| 837 | ||
| 838 | // Create new content, which is not published |
|
| 839 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 840 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 841 | $contentCreate->setField('name', 'New Folder'); |
|
| 842 | $content = $contentService->createContent($contentCreate); |
|
| 843 | ||
| 844 | // Throws Exception, since $content has no published version, yet |
|
| 845 | $locationService->loadLocations( |
|
| 846 | $content->contentInfo |
|
| 847 | ); |
|
| 848 | /* END: Use Case */ |
|
| 849 | } |
|
| 850 | ||
| 851 | /** |
|
| 852 | * Test for the loadLocations() method. |
|
| @@ 2846-2867 (lines=22) @@ | ||
| 2843 | * |
|
| 2844 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2845 | */ |
|
| 2846 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2847 | { |
|
| 2848 | $repository = $this->getRepository(false); |
|
| 2849 | $locationService = $repository->getLocationService(); |
|
| 2850 | ||
| 2851 | $contentService = $repository->getContentService(); |
|
| 2852 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2853 | ||
| 2854 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2855 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2856 | 'eng-US' |
|
| 2857 | ); |
|
| 2858 | $contentCreateStruct->setField('name', $contentName); |
|
| 2859 | $contentDraft = $contentService->createContent( |
|
| 2860 | $contentCreateStruct, |
|
| 2861 | [ |
|
| 2862 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2863 | ] |
|
| 2864 | ); |
|
| 2865 | ||
| 2866 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2867 | } |
|
| 2868 | } |
|
| 2869 | ||
| @@ 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 |
|