| @@ 841-856 (lines=16) @@ | ||
| 838 | * |
|
| 839 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 840 | */ |
|
| 841 | protected function createNewContentInPlaceTrashedOne(Repository $repository, $parentLocationId) |
|
| 842 | { |
|
| 843 | $contentService = $repository->getContentService(); |
|
| 844 | $locationService = $repository->getLocationService(); |
|
| 845 | $contentTypeService = $repository->getContentTypeService(); |
|
| 846 | ||
| 847 | $contentType = $contentTypeService->loadContentTypeByIdentifier('forum'); |
|
| 848 | $newContent = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
|
| 849 | $newContent->setField('name', 'Media'); |
|
| 850 | ||
| 851 | $location = $locationService->newLocationCreateStruct($parentLocationId); |
|
| 852 | ||
| 853 | $draftContent = $contentService->createContent($newContent, [$location]); |
|
| 854 | ||
| 855 | return $contentService->publishVersion($draftContent->versionInfo); |
|
| 856 | } |
|
| 857 | ||
| 858 | /** |
|
| 859 | * @param URLAliasService $urlAliasService |
|
| @@ 635-655 (lines=21) @@ | ||
| 632 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
|
| 633 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 634 | */ |
|
| 635 | public function testLoadLocationsThrowsBadStateException() |
|
| 636 | { |
|
| 637 | $repository = $this->getRepository(); |
|
| 638 | ||
| 639 | /* BEGIN: Use Case */ |
|
| 640 | $contentTypeService = $repository->getContentTypeService(); |
|
| 641 | $contentService = $repository->getContentService(); |
|
| 642 | $locationService = $repository->getLocationService(); |
|
| 643 | ||
| 644 | // Create new content, which is not published |
|
| 645 | $folderType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
|
| 646 | $contentCreate = $contentService->newContentCreateStruct($folderType, 'eng-US'); |
|
| 647 | $contentCreate->setField('name', 'New Folder'); |
|
| 648 | $content = $contentService->createContent($contentCreate); |
|
| 649 | ||
| 650 | // Throws Exception, since $content has no published version, yet |
|
| 651 | $locationService->loadLocations( |
|
| 652 | $content->contentInfo |
|
| 653 | ); |
|
| 654 | /* END: Use Case */ |
|
| 655 | } |
|
| 656 | ||
| 657 | /** |
|
| 658 | * Test for the loadLocations() method. |
|