| @@ 247-274 (lines=28) @@ | ||
| 244 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 245 | * @depends eZ\Publish\API\Repository\Tests\ObjectStateServiceTest::testSetPriorityOfObjectState |
|
| 246 | */ |
|
| 247 | public function testSetPriorityOfObjectStateThrowsUnauthorizedException() |
|
| 248 | { |
|
| 249 | $repository = $this->getRepository(); |
|
| 250 | ||
| 251 | $objectStateId = $this->generateId('objectstate', 2); |
|
| 252 | $anonymousUserId = $this->generateId('user', 10); |
|
| 253 | /* BEGIN: Use Case */ |
|
| 254 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 255 | // Publish demo installation. |
|
| 256 | // Set anonymous user |
|
| 257 | $userService = $repository->getUserService(); |
|
| 258 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 259 | ||
| 260 | // $objectStateId contains the ID of the "locked" state |
|
| 261 | $objectStateService = $repository->getObjectStateService(); |
|
| 262 | ||
| 263 | $initiallyLoadedObjectState = $objectStateService->loadObjectState( |
|
| 264 | $objectStateId |
|
| 265 | ); |
|
| 266 | ||
| 267 | // Throws unauthorized exception, since the anonymous user must not |
|
| 268 | // set priorities for object states |
|
| 269 | $objectStateService->setPriorityOfObjectState( |
|
| 270 | $initiallyLoadedObjectState, |
|
| 271 | 23 |
|
| 272 | ); |
|
| 273 | /* END: Use Case */ |
|
| 274 | } |
|
| 275 | ||
| 276 | /** |
|
| 277 | * Test for the deleteObjectState() method. |
|
| @@ 1067-1097 (lines=31) @@ | ||
| 1064 | * @see \eZ\Publish\API\Repository\ObjectStateService::setPriorityOfObjectState() |
|
| 1065 | * @depends testLoadObjectState |
|
| 1066 | */ |
|
| 1067 | public function testSetPriorityOfObjectState() |
|
| 1068 | { |
|
| 1069 | $repository = $this->getRepository(); |
|
| 1070 | ||
| 1071 | $objectStateId = $this->generateId('objectstate', 1); |
|
| 1072 | /* BEGIN: Use Case */ |
|
| 1073 | // $objectStateId contains the ID of the "not_locked" state |
|
| 1074 | $objectStateService = $repository->getObjectStateService(); |
|
| 1075 | ||
| 1076 | $initiallyLoadedObjectState = $objectStateService->loadObjectState( |
|
| 1077 | $objectStateId |
|
| 1078 | ); |
|
| 1079 | ||
| 1080 | // Sets the given priority on $initiallyLoadedObjectState |
|
| 1081 | $objectStateService->setPriorityOfObjectState( |
|
| 1082 | $initiallyLoadedObjectState, |
|
| 1083 | 23 |
|
| 1084 | ); |
|
| 1085 | // $loadObjectState now has the priority 1, since object state |
|
| 1086 | // priorities are always made sequential |
|
| 1087 | $loadedObjectState = $objectStateService->loadObjectState( |
|
| 1088 | $objectStateId |
|
| 1089 | ); |
|
| 1090 | /* END: Use Case */ |
|
| 1091 | ||
| 1092 | $this->assertInstanceOf( |
|
| 1093 | 'eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState', |
|
| 1094 | $loadedObjectState |
|
| 1095 | ); |
|
| 1096 | $this->assertEquals(1, $loadedObjectState->priority); |
|
| 1097 | } |
|
| 1098 | ||
| 1099 | /** |
|
| 1100 | * Test for the getContentState() method. |
|
| @@ 1324-1348 (lines=25) @@ | ||
| 1321 | * @see \eZ\Publish\API\Repository\ObjectStateService::deleteObjectState() |
|
| 1322 | * @depends testLoadObjectState |
|
| 1323 | */ |
|
| 1324 | public function testDeleteObjectState() |
|
| 1325 | { |
|
| 1326 | $repository = $this->getRepository(); |
|
| 1327 | ||
| 1328 | $notLockedObjectStateId = $this->generateId('objectstate', 1); |
|
| 1329 | $lockedObjectStateId = $this->generateId('objectstate', 2); |
|
| 1330 | /* BEGIN: Use Case */ |
|
| 1331 | // $notLockedObjectStateId is the ID of the state "not_locked" |
|
| 1332 | $objectStateService = $repository->getObjectStateService(); |
|
| 1333 | ||
| 1334 | $notLockedObjectState = $objectStateService->loadObjectState($notLockedObjectStateId); |
|
| 1335 | ||
| 1336 | // Deletes the object state and sets all objects, which where in that |
|
| 1337 | // state, to the first state of the same object state group |
|
| 1338 | $objectStateService->deleteObjectState($notLockedObjectState); |
|
| 1339 | /* END: Use Case */ |
|
| 1340 | ||
| 1341 | $lockedObjectState = $objectStateService->loadObjectState($lockedObjectStateId); |
|
| 1342 | ||
| 1343 | // All objects transferred |
|
| 1344 | $this->assertEquals( |
|
| 1345 | 18, |
|
| 1346 | $objectStateService->getContentCount($lockedObjectState) |
|
| 1347 | ); |
|
| 1348 | } |
|
| 1349 | ||
| 1350 | /** |
|
| 1351 | * Test for the deleteObjectStateGroup() method. |
|