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