| @@ 97-118 (lines=22) @@ | ||
| 94 | /** |
|
| 95 | * @return Content |
|
| 96 | */ |
|
| 97 | private function createFolder() |
|
| 98 | { |
|
| 99 | $repository = $this->getRepository(); |
|
| 100 | $contentService = $repository->getContentService(); |
|
| 101 | $contentTypeService = $repository->getContentTypeService(); |
|
| 102 | $locationService = $repository->getLocationService(); |
|
| 103 | ||
| 104 | $struct = $contentService->newContentCreateStruct( |
|
| 105 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 106 | 'eng-GB' |
|
| 107 | ); |
|
| 108 | ||
| 109 | $struct->setField('name', uniqid('Query Controller BDD ', true)); |
|
| 110 | ||
| 111 | $contentDraft = $contentService->createContent( |
|
| 112 | $struct, |
|
| 113 | [$locationService->newLocationCreateStruct(2)] |
|
| 114 | ); |
|
| 115 | $contentService->publishVersion($contentDraft->versionInfo); |
|
| 116 | ||
| 117 | return $contentService->loadContent($contentDraft->id); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * @Given /^a LocationChildren QueryType defined in "([^"]*)":$/ |
|
| @@ 925-940 (lines=16) @@ | ||
| 922 | * |
|
| 923 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 924 | */ |
|
| 925 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 926 | { |
|
| 927 | $contentService = $repository->getContentService(); |
|
| 928 | $locationService = $repository->getLocationService(); |
|
| 929 | $contentTypeService = $repository->getContentTypeService(); |
|
| 930 | ||
| 931 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 932 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 933 | $newContent->setField('name', 'Media'); |
|
| 934 | ||
| 935 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 936 | ||
| 937 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 938 | ||
| 939 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 940 | } |
|
| 941 | ||
| 942 | /** |
|
| 943 | * @param URLAliasService $urlAliasService |
|
| @@ 2907-2928 (lines=22) @@ | ||
| 2904 | * |
|
| 2905 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2906 | */ |
|
| 2907 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2908 | { |
|
| 2909 | $repository = $this->getRepository(false); |
|
| 2910 | $locationService = $repository->getLocationService(); |
|
| 2911 | ||
| 2912 | $contentService = $repository->getContentService(); |
|
| 2913 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2914 | ||
| 2915 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2916 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2917 | 'eng-US' |
|
| 2918 | ); |
|
| 2919 | $contentCreateStruct->setField('name', $contentName); |
|
| 2920 | $contentDraft = $contentService->createContent( |
|
| 2921 | $contentCreateStruct, |
|
| 2922 | [ |
|
| 2923 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2924 | ] |
|
| 2925 | ); |
|
| 2926 | ||
| 2927 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2928 | } |
|
| 2929 | } |
|
| 2930 | ||
| @@ 843-863 (lines=21) @@ | ||
| 840 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 841 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 842 | */ |
|
| 843 | public function testLoadLocationsThrowsBadStateException() |
|
| 844 | { |
|
| 845 | $repository = $this->getRepository(); |
|
| 846 | ||
| 847 | /* BEGIN: Use Case */ |
|
| 848 | $contentTypeService = $repository->getContentTypeService(); |
|
| 849 | $contentService = $repository->getContentService(); |
|
| 850 | $locationService = $repository->getLocationService(); |
|
| 851 | ||
| 852 | // Create new content, which is not published |
|
| 853 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 854 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 855 | $contentCreate->setField('name', 'New Folder'); |
|
| 856 | $content = $contentService->createContent($contentCreate); |
|
| 857 | ||
| 858 | // Throws Exception, since $content has no published version, yet |
|
| 859 | $locationService->loadLocations( |
|
| 860 | $content->contentInfo |
|
| 861 | ); |
|
| 862 | /* END: Use Case */ |
|
| 863 | } |
|
| 864 | ||
| 865 | /** |
|
| 866 | * Test for the loadLocations() method. |
|