| @@ 57-82 (lines=26) @@ | ||
| 54 | * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash |
|
| 55 | * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testLoadAnonymousUser |
|
| 56 | */ |
|
| 57 | public function testTrashThrowsUnauthorizedException() |
|
| 58 | { |
|
| 59 | $repository = $this->getRepository(); |
|
| 60 | ||
| 61 | $anonymousUserId = $this->generateId('user', 10); |
|
| 62 | /* BEGIN: Inline */ |
|
| 63 | // $anonymousUserId is the ID of the "Anonymous" user |
|
| 64 | // remoteId of the "Media" page main location |
|
| 65 | $mediaRemoteId = '75c715a51699d2d309a924eca6a95145'; |
|
| 66 | ||
| 67 | $userService = $repository->getUserService(); |
|
| 68 | $trashService = $repository->getTrashService(); |
|
| 69 | $locationService = $repository->getLocationService(); |
|
| 70 | ||
| 71 | // Load "Media" page location |
|
| 72 | $mediaLocation = $locationService->loadLocationByRemoteId( |
|
| 73 | $mediaRemoteId |
|
| 74 | ); |
|
| 75 | ||
| 76 | // Set "Anonymous" as current user |
|
| 77 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 78 | ||
| 79 | // This call will fail with an "UnauthorizedException" |
|
| 80 | $trashService->trash($mediaLocation); |
|
| 81 | /* END: Inline */ |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Test for the recover() method. |
|
| @@ 269-286 (lines=18) @@ | ||
| 266 | * |
|
| 267 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
| 268 | */ |
|
| 269 | public function testNotFoundAliasAfterRemoveIt() |
|
| 270 | { |
|
| 271 | $mediaRemoteId = '75c715a51699d2d309a924eca6a95145'; |
|
| 272 | ||
| 273 | $repository = $this->getRepository(); |
|
| 274 | $trashService = $repository->getTrashService(); |
|
| 275 | $urlAliasService = $repository->getURLAliasService(); |
|
| 276 | $locationService = $repository->getLocationService(); |
|
| 277 | ||
| 278 | // Double ->lookup() call because there where issue that one call was not enough to spot bug |
|
| 279 | $urlAliasService->lookup('/Media'); |
|
| 280 | $urlAliasService->lookup('/Media'); |
|
| 281 | ||
| 282 | $mediaLocation = $locationService->loadLocationByRemoteId($mediaRemoteId); |
|
| 283 | $trashService->trash($mediaLocation); |
|
| 284 | ||
| 285 | $urlAliasService->lookup('/Media'); |
|
| 286 | } |
|
| 287 | ||
| 288 | /** |
|
| 289 | * Test for the recover() method. |
|