| @@ 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 "([^"]*)":$/ |
|
| @@ 623-643 (lines=21) @@ | ||
| 620 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 621 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 622 | */ |
|
| 623 | public function testLoadLocationsThrowsBadStateException() |
|
| 624 | { |
|
| 625 | $repository = $this->getRepository(); |
|
| 626 | ||
| 627 | /* BEGIN: Use Case */ |
|
| 628 | $contentTypeService = $repository->getContentTypeService(); |
|
| 629 | $contentService = $repository->getContentService(); |
|
| 630 | $locationService = $repository->getLocationService(); |
|
| 631 | ||
| 632 | // Create new content, which is not published |
|
| 633 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 634 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 635 | $contentCreate->setField('name', 'New Folder'); |
|
| 636 | $content = $contentService->createContent($contentCreate); |
|
| 637 | ||
| 638 | // Throws Exception, since $content has no published version, yet |
|
| 639 | $locationService->loadLocations( |
|
| 640 | $content->contentInfo |
|
| 641 | ); |
|
| 642 | /* END: Use Case */ |
|
| 643 | } |
|
| 644 | ||
| 645 | /** |
|
| 646 | * Test for the loadLocations() method. |
|
| @@ 716-731 (lines=16) @@ | ||
| 713 | * |
|
| 714 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 715 | */ |
|
| 716 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 717 | { |
|
| 718 | $contentService = $repository->getContentService(); |
|
| 719 | $locationService = $repository->getLocationService(); |
|
| 720 | $contentTypeService = $repository->getContentTypeService(); |
|
| 721 | ||
| 722 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 723 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 724 | $newContent->setField('name', 'Media'); |
|
| 725 | ||
| 726 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 727 | ||
| 728 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 729 | ||
| 730 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 731 | } |
|
| 732 | ||
| 733 | /** |
|
| 734 | * @param URLAliasService $urlAliasService |
|