| @@ 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 "([^"]*)":$/ |
|
| @@ 834-849 (lines=16) @@ | ||
| 831 | * |
|
| 832 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 833 | */ |
|
| 834 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 835 | { |
|
| 836 | $contentService = $repository->getContentService(); |
|
| 837 | $locationService = $repository->getLocationService(); |
|
| 838 | $contentTypeService = $repository->getContentTypeService(); |
|
| 839 | ||
| 840 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 841 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 842 | $newContent->setField('name', 'Media'); |
|
| 843 | ||
| 844 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 845 | ||
| 846 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 847 | ||
| 848 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 849 | } |
|
| 850 | ||
| 851 | /** |
|
| 852 | * @param URLAliasService $urlAliasService |
|
| @@ 676-696 (lines=21) @@ | ||
| 673 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 674 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 675 | */ |
|
| 676 | public function testLoadLocationsThrowsBadStateException() |
|
| 677 | { |
|
| 678 | $repository = $this->getRepository(); |
|
| 679 | ||
| 680 | /* BEGIN: Use Case */ |
|
| 681 | $contentTypeService = $repository->getContentTypeService(); |
|
| 682 | $contentService = $repository->getContentService(); |
|
| 683 | $locationService = $repository->getLocationService(); |
|
| 684 | ||
| 685 | // Create new content, which is not published |
|
| 686 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 687 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 688 | $contentCreate->setField('name', 'New Folder'); |
|
| 689 | $content = $contentService->createContent($contentCreate); |
|
| 690 | ||
| 691 | // Throws Exception, since $content has no published version, yet |
|
| 692 | $locationService->loadLocations( |
|
| 693 | $content->contentInfo |
|
| 694 | ); |
|
| 695 | /* END: Use Case */ |
|
| 696 | } |
|
| 697 | ||
| 698 | /** |
|
| 699 | * Test for the loadLocations() method. |
|
| @@ 2437-2458 (lines=22) @@ | ||
| 2434 | * |
|
| 2435 | * @return \eZ\Publish\API\Repository\Values\Content\Content published Content |
|
| 2436 | */ |
|
| 2437 | private function publishContentWithParentLocation($contentName, $parentLocationId) |
|
| 2438 | { |
|
| 2439 | $repository = $this->getRepository(false); |
|
| 2440 | $locationService = $repository->getLocationService(); |
|
| 2441 | ||
| 2442 | $contentService = $repository->getContentService(); |
|
| 2443 | $contentTypeService = $repository->getContentTypeService(); |
|
| 2444 | ||
| 2445 | $contentCreateStruct = $contentService->newContentCreateStruct( |
|
| 2446 | $contentTypeService->loadContentTypeByIdentifier('folder'), |
|
| 2447 | 'eng-US' |
|
| 2448 | ); |
|
| 2449 | $contentCreateStruct->setField('name', $contentName); |
|
| 2450 | $contentDraft = $contentService->createContent( |
|
| 2451 | $contentCreateStruct, |
|
| 2452 | [ |
|
| 2453 | $locationService->newLocationCreateStruct($parentLocationId), |
|
| 2454 | ] |
|
| 2455 | ); |
|
| 2456 | ||
| 2457 | return $contentService->publishVersion($contentDraft->versionInfo); |
|
| 2458 | } |
|
| 2459 | } |
|
| 2460 | ||