| @@ 268-292 (lines=25) @@ | ||
| 265 | * |
|
| 266 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
|
| 267 | */ |
|
| 268 | protected function createMultipleLanguageDraftVersion1() |
|
| 269 | { |
|
| 270 | $repository = $this->getRepository(); |
|
| 271 | ||
| 272 | $contentService = $repository->getContentService(); |
|
| 273 | ||
| 274 | /* BEGIN: Inline */ |
|
| 275 | $draft = $this->createContentDraftVersion1(); |
|
| 276 | ||
| 277 | $contentUpdate = $contentService->newContentUpdateStruct(); |
|
| 278 | ||
| 279 | $contentUpdate->initialLanguageCode = 'eng-US'; |
|
| 280 | ||
| 281 | $contentUpdate->setField('name', 'An awesome multi-lang forum²'); |
|
| 282 | ||
| 283 | $contentUpdate->setField('name', 'An awesome multi-lang forum²³', 'eng-GB'); |
|
| 284 | ||
| 285 | $draft = $contentService->updateContent( |
|
| 286 | $draft->getVersionInfo(), |
|
| 287 | $contentUpdate |
|
| 288 | ); |
|
| 289 | /* END: Inline */ |
|
| 290 | ||
| 291 | return $draft; |
|
| 292 | } |
|
| 293 | ||
| 294 | /** |
|
| 295 | * Creates a published content object with versionNo=2 named |
|
| @@ 406-432 (lines=27) @@ | ||
| 403 | * |
|
| 404 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
|
| 405 | */ |
|
| 406 | private function createUserGroupVersion1() |
|
| 407 | { |
|
| 408 | $repository = $this->getRepository(); |
|
| 409 | ||
| 410 | $mainGroupId = $this->generateId('group', 4); |
|
| 411 | /* BEGIN: Inline */ |
|
| 412 | // $mainGroupId is the ID of the main "Users" group in an eZ Publish |
|
| 413 | // demo installation |
|
| 414 | ||
| 415 | $userService = $repository->getUserService(); |
|
| 416 | ||
| 417 | // Load main group |
|
| 418 | $parentUserGroup = $userService->loadUserGroup($mainGroupId); |
|
| 419 | ||
| 420 | // Instantiate a new create struct |
|
| 421 | $userGroupCreate = $userService->newUserGroupCreateStruct('eng-US'); |
|
| 422 | $userGroupCreate->setField('name', 'Example Group'); |
|
| 423 | ||
| 424 | // Create the new user group |
|
| 425 | $userGroup = $userService->createUserGroup( |
|
| 426 | $userGroupCreate, |
|
| 427 | $parentUserGroup |
|
| 428 | ); |
|
| 429 | /* END: Inline */ |
|
| 430 | ||
| 431 | return $userGroup; |
|
| 432 | } |
|
| 433 | } |
|
| 434 | ||
| @@ 2590-2615 (lines=26) @@ | ||
| 2587 | * |
|
| 2588 | * @return \eZ\Publish\API\Repository\Values\User\UserGroup |
|
| 2589 | */ |
|
| 2590 | private function createUserGroupVersion1() |
|
| 2591 | { |
|
| 2592 | $repository = $this->getRepository(); |
|
| 2593 | ||
| 2594 | $mainGroupId = $this->generateId('group', 4); |
|
| 2595 | /* BEGIN: Inline */ |
|
| 2596 | // $mainGroupId is the ID of the main "Users" group |
|
| 2597 | ||
| 2598 | $userService = $repository->getUserService(); |
|
| 2599 | ||
| 2600 | // Load main group |
|
| 2601 | $parentUserGroup = $userService->loadUserGroup($mainGroupId); |
|
| 2602 | ||
| 2603 | // Instantiate a new create struct |
|
| 2604 | $userGroupCreate = $userService->newUserGroupCreateStruct('eng-US'); |
|
| 2605 | $userGroupCreate->setField('name', 'Example Group'); |
|
| 2606 | ||
| 2607 | // Create the new user group |
|
| 2608 | $userGroup = $userService->createUserGroup( |
|
| 2609 | $userGroupCreate, |
|
| 2610 | $parentUserGroup |
|
| 2611 | ); |
|
| 2612 | /* END: Inline */ |
|
| 2613 | ||
| 2614 | return $userGroup; |
|
| 2615 | } |
|
| 2616 | ||
| 2617 | /** |
|
| 2618 | * Create user with multiple translations of User Content fields. |
|
| @@ 1638-1661 (lines=24) @@ | ||
| 1635 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
|
| 1636 | * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContent |
|
| 1637 | */ |
|
| 1638 | public function testUpdateContentThrowsBadStateException() |
|
| 1639 | { |
|
| 1640 | $repository = $this->getRepository(); |
|
| 1641 | ||
| 1642 | $contentService = $repository->getContentService(); |
|
| 1643 | ||
| 1644 | /* BEGIN: Use Case */ |
|
| 1645 | $content = $this->createContentVersion1(); |
|
| 1646 | ||
| 1647 | // Now create an update struct and modify some fields |
|
| 1648 | $contentUpdateStruct = $contentService->newContentUpdateStruct(); |
|
| 1649 | $contentUpdateStruct->setField('title', 'An awesome² story about ezp.'); |
|
| 1650 | $contentUpdateStruct->setField('title', 'An awesome²³ story about ezp.', 'eng-GB'); |
|
| 1651 | ||
| 1652 | $contentUpdateStruct->initialLanguageCode = 'eng-US'; |
|
| 1653 | ||
| 1654 | // This call will fail with a "BadStateException", because $publishedContent |
|
| 1655 | // is not a draft. |
|
| 1656 | $contentService->updateContent( |
|
| 1657 | $content->getVersionInfo(), |
|
| 1658 | $contentUpdateStruct |
|
| 1659 | ); |
|
| 1660 | /* END: Use Case */ |
|
| 1661 | } |
|
| 1662 | ||
| 1663 | /** |
|
| 1664 | * Test for the updateContent() method. |
|