| @@ 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. |
|
| @@ 1122-1153 (lines=32) @@ | ||
| 1119 | * @see \eZ\Publish\API\Repository\ObjectStateService::updateObjectState() |
|
| 1120 | * @depends testUpdateObjectState |
|
| 1121 | */ |
|
| 1122 | public function testUpdateObjectStateThrowsInvalidArgumentException() |
|
| 1123 | { |
|
| 1124 | $repository = $this->getRepository(); |
|
| 1125 | ||
| 1126 | $objectStateId = $this->generateId('objectstate', 2); |
|
| 1127 | // $objectStateId contains the ID of the "locked" state |
|
| 1128 | $objectStateService = $repository->getObjectStateService(); |
|
| 1129 | ||
| 1130 | $loadedObjectState = $objectStateService->loadObjectState( |
|
| 1131 | $objectStateId |
|
| 1132 | ); |
|
| 1133 | ||
| 1134 | $updateStateStruct = $objectStateService->newObjectStateUpdateStruct(); |
|
| 1135 | // 'not_locked' is the identifier of already existing state |
|
| 1136 | $updateStateStruct->identifier = 'not_locked'; |
|
| 1137 | $updateStateStruct->defaultLanguageCode = 'ger-DE'; |
|
| 1138 | $updateStateStruct->names = array( |
|
| 1139 | 'eng-US' => 'Somehow locked', |
|
| 1140 | 'ger-DE' => 'Irgendwie gelockt', |
|
| 1141 | ); |
|
| 1142 | $updateStateStruct->descriptions = array( |
|
| 1143 | 'eng-US' => 'The object is somehow locked', |
|
| 1144 | 'ger-DE' => 'Sindelfingen', |
|
| 1145 | ); |
|
| 1146 | ||
| 1147 | // This call will fail because state with |
|
| 1148 | // 'not_locked' identifier already exists |
|
| 1149 | $objectStateService->updateObjectState( |
|
| 1150 | $loadedObjectState, |
|
| 1151 | $updateStateStruct |
|
| 1152 | ); |
|
| 1153 | } |
|
| 1154 | ||
| 1155 | /** |
|
| 1156 | * testUpdateObjectStateStructValues. |
|