| @@ 71-88 (lines=18) @@ | ||
| 68 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 69 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 70 | */ |
|
| 71 | public function testLoadLocationThrowsUnauthorizedException() |
|
| 72 | { |
|
| 73 | $repository = $this->getRepository(); |
|
| 74 | ||
| 75 | $editorsGroupId = $this->generateId('group', 13); |
|
| 76 | ||
| 77 | /* BEGIN: Use Case */ |
|
| 78 | $locationService = $repository->getLocationService(); |
|
| 79 | ||
| 80 | $user = $this->createUserVersion1(); |
|
| 81 | ||
| 82 | // Set current user to newly created user |
|
| 83 | $repository->setCurrentUser($user); |
|
| 84 | ||
| 85 | // This call will fail with an "UnauthorizedException" |
|
| 86 | $locationService->loadLocation($editorsGroupId); |
|
| 87 | /* END: Use Case */ |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * Test for the loadLocationByRemoteId() method. |
|
| @@ 97-115 (lines=19) @@ | ||
| 94 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 95 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationByRemoteId |
|
| 96 | */ |
|
| 97 | public function testLoadLocationByRemoteIdThrowsUnauthorizedException() |
|
| 98 | { |
|
| 99 | $repository = $this->getRepository(); |
|
| 100 | ||
| 101 | /* BEGIN: Use Case */ |
|
| 102 | // remoteId of the "Editors" location in an eZ Publish demo installation |
|
| 103 | $editorsRemoteId = 'f7dda2854fc68f7c8455d9cb14bd04a9'; |
|
| 104 | ||
| 105 | $locationService = $repository->getLocationService(); |
|
| 106 | ||
| 107 | $user = $this->createUserVersion1(); |
|
| 108 | ||
| 109 | // Set current user to newly created user |
|
| 110 | $repository->setCurrentUser($user); |
|
| 111 | ||
| 112 | // This call will fail with an "UnauthorizedException" |
|
| 113 | $locationService->loadLocationByRemoteId($editorsRemoteId); |
|
| 114 | /* END: Use Case */ |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Test for the loadLocations() method. |
|
| @@ 451-467 (lines=17) @@ | ||
| 448 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId() |
|
| 449 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 450 | */ |
|
| 451 | public function testLoadLocationByRemoteId() |
|
| 452 | { |
|
| 453 | $repository = $this->getRepository(); |
|
| 454 | ||
| 455 | /* BEGIN: Use Case */ |
|
| 456 | $locationService = $repository->getLocationService(); |
|
| 457 | ||
| 458 | $location = $locationService->loadLocationByRemoteId( |
|
| 459 | '3f6d92f8044aed134f32153517850f5a' |
|
| 460 | ); |
|
| 461 | /* END: Use Case */ |
|
| 462 | ||
| 463 | $this->assertEquals( |
|
| 464 | $locationService->loadLocation($this->generateId('location', 5)), |
|
| 465 | $location |
|
| 466 | ); |
|
| 467 | } |
|
| 468 | ||
| 469 | /** |
|
| 470 | * Test for the loadLocationByRemoteId() method. |
|