| @@ 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 |
|
| @@ 99-120 (lines=22) @@ | ||
| 96 | /** |
|
| 97 | * @return Content |
|
| 98 | */ |
|
| 99 | private function createFolder() |
|
| 100 | { |
|
| 101 | $repository = $this->getRepository(); |
|
| 102 | $contentService = $repository->getContentService(); |
|
| 103 | $contentTypeService = $repository->getContentTypeService(); |
|
| 104 | $locationService = $repository->getLocationService(); |
|
| 105 | ||
| 106 | $struct = $contentService->newContentCreateStruct( |
|
| 107 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 108 | 'eng-GB' |
|
| 109 | ); |
|
| 110 | ||
| 111 | $struct->setField('name', uniqid('Query Controller BDD ', true)); |
|
| 112 | ||
| 113 | $contentDraft = $contentService->createContent( |
|
| 114 | $struct, |
|
| 115 | [$locationService->newLocationCreateStruct(2)] |
|
| 116 | ); |
|
| 117 | $contentService->publishVersion($contentDraft->versionInfo); |
|
| 118 | ||
| 119 | return $contentService->loadContent($contentDraft->id); |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * @Given /^a LocationChildren QueryType defined in "([^"]*)":$/ |
|
| @@ 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. |
|
| @@ 2816-2837 (lines=22) @@ | ||
| 2813 | * |
|
| 2814 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2815 | */ |
|
| 2816 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2817 | { |
|
| 2818 | $repository = $this->getRepository(false); |
|
| 2819 | $locationService = $repository->getLocationService(); |
|
| 2820 | ||
| 2821 | $contentService = $repository->getContentService(); |
|
| 2822 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2823 | ||
| 2824 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2825 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2826 | 'eng-US' |
|
| 2827 | ); |
|
| 2828 | $contentCreateStruct->setField('name', $contentName); |
|
| 2829 | $contentDraft = $contentService->createContent( |
|
| 2830 | $contentCreateStruct, |
|
| 2831 | [ |
|
| 2832 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2833 | ] |
|
| 2834 | ); |
|
| 2835 | ||
| 2836 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2837 | } |
|
| 2838 | } |
|
| 2839 | ||