| @@ 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 ')); |
|
| 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 "([^"]*)":$/ |
|
| @@ 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 |
|
| @@ 800-820 (lines=21) @@ | ||
| 797 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 798 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 799 | */ |
|
| 800 | public function testLoadLocationsThrowsBadStateException() |
|
| 801 | { |
|
| 802 | $repository = $this->getRepository(); |
|
| 803 | ||
| 804 | /* BEGIN: Use Case */ |
|
| 805 | $contentTypeService = $repository->getContentTypeService(); |
|
| 806 | $contentService = $repository->getContentService(); |
|
| 807 | $locationService = $repository->getLocationService(); |
|
| 808 | ||
| 809 | // Create new content, which is not published |
|
| 810 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 811 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 812 | $contentCreate->setField('name', 'New Folder'); |
|
| 813 | $content = $contentService->createContent($contentCreate); |
|
| 814 | ||
| 815 | // Throws Exception, since $content has no published version, yet |
|
| 816 | $locationService->loadLocations( |
|
| 817 | $content->contentInfo |
|
| 818 | ); |
|
| 819 | /* END: Use Case */ |
|
| 820 | } |
|
| 821 | ||
| 822 | /** |
|
| 823 | * Test for the loadLocations() method. |
|
| @@ 2561-2582 (lines=22) @@ | ||
| 2558 | * |
|
| 2559 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2560 | */ |
|
| 2561 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2562 | { |
|
| 2563 | $repository = $this->getRepository(false); |
|
| 2564 | $locationService = $repository->getLocationService(); |
|
| 2565 | ||
| 2566 | $contentService = $repository->getContentService(); |
|
| 2567 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2568 | ||
| 2569 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2570 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2571 | 'eng-US' |
|
| 2572 | ); |
|
| 2573 | $contentCreateStruct->setField('name', $contentName); |
|
| 2574 | $contentDraft = $contentService->createContent( |
|
| 2575 | $contentCreateStruct, |
|
| 2576 | [ |
|
| 2577 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2578 | ] |
|
| 2579 | ); |
|
| 2580 | ||
| 2581 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2582 | } |
|
| 2583 | } |
|
| 2584 | ||