| @@ 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. |
|
| @@ 346-363 (lines=18) @@ | ||
| 343 | * |
|
| 344 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
|
| 345 | */ |
|
| 346 | public function testNotFoundAliasAfterRemoveIt() |
|
| 347 | { |
|
| 348 | $mediaRemoteId = '75c715a51699d2d309a924eca6a95145'; |
|
| 349 | ||
| 350 | $repository = $this->getRepository(); |
|
| 351 | $trashService = $repository->getTrashService(); |
|
| 352 | $urlAliasService = $repository->getURLAliasService(); |
|
| 353 | $locationService = $repository->getLocationService(); |
|
| 354 | ||
| 355 | // Double ->lookup() call because there where issue that one call was not enough to spot bug |
|
| 356 | $urlAliasService->lookup('/Media'); |
|
| 357 | $urlAliasService->lookup('/Media'); |
|
| 358 | ||
| 359 | $mediaLocation = $locationService->loadLocationByRemoteId($mediaRemoteId); |
|
| 360 | $trashService->trash($mediaLocation); |
|
| 361 | ||
| 362 | $urlAliasService->lookup('/Media'); |
|
| 363 | } |
|
| 364 | ||
| 365 | /** |
|
| 366 | * Test for the recover() method. |
|