| @@ 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. |
|
| @@ 36-56 (lines=21) @@ | ||
| 33 | * |
|
| 34 | * @see \eZ\Publish\API\Repository\LocationService::newLocationCreateStruct() |
|
| 35 | */ |
|
| 36 | public function testNewLocationCreateStruct() |
|
| 37 | { |
|
| 38 | $repository = $this->getRepository(); |
|
| 39 | ||
| 40 | $parentLocationId = $this->generateId('location', 1); |
|
| 41 | /* BEGIN: Use Case */ |
|
| 42 | // $parentLocationId is the ID of an existing location |
|
| 43 | $locationService = $repository->getLocationService(); |
|
| 44 | ||
| 45 | $locationCreate = $locationService->newLocationCreateStruct( |
|
| 46 | $parentLocationId |
|
| 47 | ); |
|
| 48 | /* END: Use Case */ |
|
| 49 | ||
| 50 | $this->assertInstanceOf( |
|
| 51 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\LocationCreateStruct', |
|
| 52 | $locationCreate |
|
| 53 | ); |
|
| 54 | ||
| 55 | return $locationCreate; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Test for the newLocationCreateStruct() method. |
|
| @@ 453-469 (lines=17) @@ | ||
| 450 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId() |
|
| 451 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 452 | */ |
|
| 453 | public function testLoadLocationByRemoteId() |
|
| 454 | { |
|
| 455 | $repository = $this->getRepository(); |
|
| 456 | ||
| 457 | /* BEGIN: Use Case */ |
|
| 458 | $locationService = $repository->getLocationService(); |
|
| 459 | ||
| 460 | $location = $locationService->loadLocationByRemoteId( |
|
| 461 | '3f6d92f8044aed134f32153517850f5a' |
|
| 462 | ); |
|
| 463 | /* END: Use Case */ |
|
| 464 | ||
| 465 | $this->assertEquals( |
|
| 466 | $locationService->loadLocation($this->generateId('location', 5)), |
|
| 467 | $location |
|
| 468 | ); |
|
| 469 | } |
|
| 470 | ||
| 471 | /** |
|
| 472 | * Test for the loadLocationByRemoteId() method. |
|