| @@ 78-96 (lines=19) @@ | ||
| 75 | * @see \eZ\Publish\API\Repository\URLService::loadById |
|
| 76 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 77 | */ |
|
| 78 | public function testLoadByIdThrowsUnauthorizedException() |
|
| 79 | { |
|
| 80 | $repository = $this->getRepository(); |
|
| 81 | ||
| 82 | $anonymousUserId = $this->generateId('user', 10); |
|
| 83 | $urlId = $this->generateId('url', 23); |
|
| 84 | /* BEGIN: Use Case */ |
|
| 85 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 86 | // Publish demo installation. |
|
| 87 | ||
| 88 | $userService = $repository->getUserService(); |
|
| 89 | $urlService = $repository->getURLService(); |
|
| 90 | ||
| 91 | $repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
|
| 92 | ||
| 93 | // This call will fail with an UnauthorizedException |
|
| 94 | $urlService->loadById($urlId); |
|
| 95 | /* END: Use Case */ |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * Test for the loadByUrl() method. |
|
| @@ 541-557 (lines=17) @@ | ||
| 538 | * @expectedException \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException |
|
| 539 | * @depends eZ\Publish\API\Repository\Tests\URLServiceTest::testUpdateUrl |
|
| 540 | */ |
|
| 541 | public function testUpdateUrlWithNonUniqueUrl() |
|
| 542 | { |
|
| 543 | $repository = $this->getRepository(); |
|
| 544 | ||
| 545 | $id = $this->generateId('url', 23); |
|
| 546 | ||
| 547 | /* BEGIN: Use Case */ |
|
| 548 | $urlService = $repository->getURLService(); |
|
| 549 | ||
| 550 | $urlBeforeUpdate = $urlService->loadById($id); |
|
| 551 | $updateStruct = $urlService->createUpdateStruct(); |
|
| 552 | $updateStruct->url = 'http://www.youtube.com/'; |
|
| 553 | ||
| 554 | // This call will fail with a InvalidArgumentException |
|
| 555 | $urlService->updateUrl($urlBeforeUpdate, $updateStruct); |
|
| 556 | /* END: Use Case */ |
|
| 557 | } |
|
| 558 | ||
| 559 | /** |
|
| 560 | * Test for URLService::loadById() method. |
|