| @@ 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 "([^"]*)":$/ |
|
| @@ 875-890 (lines=16) @@ | ||
| 872 | * |
|
| 873 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 874 | */ |
|
| 875 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 876 | { |
|
| 877 | $contentService = $repository->getContentService(); |
|
| 878 | $locationService = $repository->getLocationService(); |
|
| 879 | $contentTypeService = $repository->getContentTypeService(); |
|
| 880 | ||
| 881 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 882 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 883 | $newContent->setField('name', 'Media'); |
|
| 884 | ||
| 885 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 886 | ||
| 887 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 888 | ||
| 889 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 890 | } |
|
| 891 | ||
| 892 | /** |
|
| 893 | * @param URLAliasService $urlAliasService |
|
| @@ 822-842 (lines=21) @@ | ||
| 819 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 820 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 821 | */ |
|
| 822 | public function testLoadLocationsThrowsBadStateException() |
|
| 823 | { |
|
| 824 | $repository = $this->getRepository(); |
|
| 825 | ||
| 826 | /* BEGIN: Use Case */ |
|
| 827 | $contentTypeService = $repository->getContentTypeService(); |
|
| 828 | $contentService = $repository->getContentService(); |
|
| 829 | $locationService = $repository->getLocationService(); |
|
| 830 | ||
| 831 | // Create new content, which is not published |
|
| 832 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 833 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 834 | $contentCreate->setField('name', 'New Folder'); |
|
| 835 | $content = $contentService->createContent($contentCreate); |
|
| 836 | ||
| 837 | // Throws Exception, since $content has no published version, yet |
|
| 838 | $locationService->loadLocations( |
|
| 839 | $content->contentInfo |
|
| 840 | ); |
|
| 841 | /* END: Use Case */ |
|
| 842 | } |
|
| 843 | ||
| 844 | /** |
|
| 845 | * Test for the loadLocations() method. |
|
| @@ 2836-2857 (lines=22) @@ | ||
| 2833 | * |
|
| 2834 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2835 | */ |
|
| 2836 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2837 | { |
|
| 2838 | $repository = $this->getRepository(false); |
|
| 2839 | $locationService = $repository->getLocationService(); |
|
| 2840 | ||
| 2841 | $contentService = $repository->getContentService(); |
|
| 2842 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2843 | ||
| 2844 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2845 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2846 | 'eng-US' |
|
| 2847 | ); |
|
| 2848 | $contentCreateStruct->setField('name', $contentName); |
|
| 2849 | $contentDraft = $contentService->createContent( |
|
| 2850 | $contentCreateStruct, |
|
| 2851 | [ |
|
| 2852 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2853 | ] |
|
| 2854 | ); |
|
| 2855 | ||
| 2856 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2857 | } |
|
| 2858 | } |
|
| 2859 | ||