| @@ 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. |
|
| @@ 1384-1414 (lines=31) @@ | ||
| 1381 | * @see \eZ\Publish\API\Repository\ObjectStateService::setPriorityOfObjectState() |
|
| 1382 | * @depends testLoadObjectState |
|
| 1383 | */ |
|
| 1384 | public function testSetPriorityOfObjectState() |
|
| 1385 | { |
|
| 1386 | $repository = $this->getRepository(); |
|
| 1387 | ||
| 1388 | $objectStateId = $this->generateId('objectstate', 1); |
|
| 1389 | /* BEGIN: Use Case */ |
|
| 1390 | // $objectStateId contains the ID of the "not_locked" state |
|
| 1391 | $objectStateService = $repository->getObjectStateService(); |
|
| 1392 | ||
| 1393 | $initiallyLoadedObjectState = $objectStateService->loadObjectState( |
|
| 1394 | $objectStateId |
|
| 1395 | ); |
|
| 1396 | ||
| 1397 | // Sets the given priority on $initiallyLoadedObjectState |
|
| 1398 | $objectStateService->setPriorityOfObjectState( |
|
| 1399 | $initiallyLoadedObjectState, |
|
| 1400 | 23 |
|
| 1401 | ); |
|
| 1402 | // $loadObjectState now has the priority 1, since object state |
|
| 1403 | // priorities are always made sequential |
|
| 1404 | $loadedObjectState = $objectStateService->loadObjectState( |
|
| 1405 | $objectStateId |
|
| 1406 | ); |
|
| 1407 | /* END: Use Case */ |
|
| 1408 | ||
| 1409 | $this->assertInstanceOf( |
|
| 1410 | 'eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectState', |
|
| 1411 | $loadedObjectState |
|
| 1412 | ); |
|
| 1413 | $this->assertEquals(1, $loadedObjectState->priority); |
|
| 1414 | } |
|
| 1415 | ||
| 1416 | /** |
|
| 1417 | * Test for the getContentState() method. |
|
| @@ 1640-1664 (lines=25) @@ | ||
| 1637 | * @see \eZ\Publish\API\Repository\ObjectStateService::deleteObjectState() |
|
| 1638 | * @depends testLoadObjectState |
|
| 1639 | */ |
|
| 1640 | public function testDeleteObjectState() |
|
| 1641 | { |
|
| 1642 | $repository = $this->getRepository(); |
|
| 1643 | ||
| 1644 | $notLockedObjectStateId = $this->generateId('objectstate', 1); |
|
| 1645 | $lockedObjectStateId = $this->generateId('objectstate', 2); |
|
| 1646 | /* BEGIN: Use Case */ |
|
| 1647 | // $notLockedObjectStateId is the ID of the state "not_locked" |
|
| 1648 | $objectStateService = $repository->getObjectStateService(); |
|
| 1649 | ||
| 1650 | $notLockedObjectState = $objectStateService->loadObjectState($notLockedObjectStateId); |
|
| 1651 | ||
| 1652 | // Deletes the object state and sets all objects, which where in that |
|
| 1653 | // state, to the first state of the same object state group |
|
| 1654 | $objectStateService->deleteObjectState($notLockedObjectState); |
|
| 1655 | /* END: Use Case */ |
|
| 1656 | ||
| 1657 | $lockedObjectState = $objectStateService->loadObjectState($lockedObjectStateId); |
|
| 1658 | ||
| 1659 | // All objects transferred |
|
| 1660 | $this->assertEquals( |
|
| 1661 | 18, |
|
| 1662 | $objectStateService->getContentCount($lockedObjectState) |
|
| 1663 | ); |
|
| 1664 | } |
|
| 1665 | ||
| 1666 | /** |
|
| 1667 | * Test for the deleteObjectStateGroup() method. |
|