| @@ 27-60 (lines=34) @@ | ||
| 24 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 25 | * @depends eZ\Publish\API\Repository\Tests\ObjectStateServiceTest::testCreateObjectStateGroup |
|
| 26 | */ |
|
| 27 | public function testCreateObjectStateGroupThrowsUnauthorizedException() |
|
| 28 | { |
|
| 29 | $repository = $this->getRepository(); |
|
| 30 | ||
| 31 | $anonymousUserId = $this->generateId('user', 10); |
|
| 32 | /* BEGIN: Use Case */ |
|
| 33 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 34 | // Publish demo installation. |
|
| 35 | // Set anonymous user |
|
| 36 | $userService = $repository->getUserService(); |
|
| 37 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 38 | ||
| 39 | $objectStateService = $repository->getObjectStateService(); |
|
| 40 | ||
| 41 | $objectStateGroupCreate = $objectStateService->newObjectStateGroupCreateStruct( |
|
| 42 | 'publishing' |
|
| 43 | ); |
|
| 44 | $objectStateGroupCreate->defaultLanguageCode = 'eng-US'; |
|
| 45 | $objectStateGroupCreate->names = array( |
|
| 46 | 'eng-US' => 'Publishing', |
|
| 47 | 'eng-GB' => 'Sindelfingen', |
|
| 48 | ); |
|
| 49 | $objectStateGroupCreate->descriptions = array( |
|
| 50 | 'eng-US' => 'Put something online', |
|
| 51 | 'eng-GB' => 'Put something ton Sindelfingen.', |
|
| 52 | ); |
|
| 53 | ||
| 54 | // Throws unauthorized exception, since the anonymous user must not |
|
| 55 | // create object state groups |
|
| 56 | $createdObjectStateGroup = $objectStateService->createObjectStateGroup( |
|
| 57 | $objectStateGroupCreate |
|
| 58 | ); |
|
| 59 | /* END: Use Case */ |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Test for the updateObjectStateGroup() method. |
|
| @@ 988-1019 (lines=32) @@ | ||
| 985 | * @see \eZ\Publish\API\Repository\ObjectStateService::updateObjectState() |
|
| 986 | * @depends testUpdateObjectState |
|
| 987 | */ |
|
| 988 | public function testUpdateObjectStateThrowsInvalidArgumentException() |
|
| 989 | { |
|
| 990 | $repository = $this->getRepository(); |
|
| 991 | ||
| 992 | $objectStateId = $this->generateId('objectstate', 2); |
|
| 993 | // $objectStateId contains the ID of the "locked" state |
|
| 994 | $objectStateService = $repository->getObjectStateService(); |
|
| 995 | ||
| 996 | $loadedObjectState = $objectStateService->loadObjectState( |
|
| 997 | $objectStateId |
|
| 998 | ); |
|
| 999 | ||
| 1000 | $updateStateStruct = $objectStateService->newObjectStateUpdateStruct(); |
|
| 1001 | // 'not_locked' is the identifier of already existing state |
|
| 1002 | $updateStateStruct->identifier = 'not_locked'; |
|
| 1003 | $updateStateStruct->defaultLanguageCode = 'ger-DE'; |
|
| 1004 | $updateStateStruct->names = array( |
|
| 1005 | 'eng-US' => 'Somehow locked', |
|
| 1006 | 'ger-DE' => 'Irgendwie gelockt', |
|
| 1007 | ); |
|
| 1008 | $updateStateStruct->descriptions = array( |
|
| 1009 | 'eng-US' => 'The object is somehow locked', |
|
| 1010 | 'ger-DE' => 'Sindelfingen', |
|
| 1011 | ); |
|
| 1012 | ||
| 1013 | // This call will fail because state with |
|
| 1014 | // 'not_locked' identifier already exists |
|
| 1015 | $objectStateService->updateObjectState( |
|
| 1016 | $loadedObjectState, |
|
| 1017 | $updateStateStruct |
|
| 1018 | ); |
|
| 1019 | } |
|
| 1020 | ||
| 1021 | /** |
|
| 1022 | * testUpdateObjectStateStructValues. |
|