| @@ 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 |
|
| @@ 739-759 (lines=21) @@ | ||
| 736 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 737 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 738 | */ |
|
| 739 | public function testLoadLocationsThrowsBadStateException() |
|
| 740 | { |
|
| 741 | $repository = $this->getRepository(); |
|
| 742 | ||
| 743 | /* BEGIN: Use Case */ |
|
| 744 | $contentTypeService = $repository->getContentTypeService(); |
|
| 745 | $contentService = $repository->getContentService(); |
|
| 746 | $locationService = $repository->getLocationService(); |
|
| 747 | ||
| 748 | // Create new content, which is not published |
|
| 749 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 750 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 751 | $contentCreate->setField('name', 'New Folder'); |
|
| 752 | $content = $contentService->createContent($contentCreate); |
|
| 753 | ||
| 754 | // Throws Exception, since $content has no published version, yet |
|
| 755 | $locationService->loadLocations( |
|
| 756 | $content->contentInfo |
|
| 757 | ); |
|
| 758 | /* END: Use Case */ |
|
| 759 | } |
|
| 760 | ||
| 761 | /** |
|
| 762 | * Test for the loadLocations() method. |
|
| @@ 2712-2733 (lines=22) @@ | ||
| 2709 | * |
|
| 2710 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2711 | */ |
|
| 2712 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2713 | { |
|
| 2714 | $repository = $this->getRepository(false); |
|
| 2715 | $locationService = $repository->getLocationService(); |
|
| 2716 | ||
| 2717 | $contentService = $repository->getContentService(); |
|
| 2718 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2719 | ||
| 2720 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2721 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2722 | 'eng-US' |
|
| 2723 | ); |
|
| 2724 | $contentCreateStruct->setField('name', $contentName); |
|
| 2725 | $contentDraft = $contentService->createContent( |
|
| 2726 | $contentCreateStruct, |
|
| 2727 | [ |
|
| 2728 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2729 | ] |
|
| 2730 | ); |
|
| 2731 | ||
| 2732 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2733 | } |
|
| 2734 | } |
|
| 2735 | ||