| @@ 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. |
|
| @@ 543-559 (lines=17) @@ | ||
| 540 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId() |
|
| 541 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 542 | */ |
|
| 543 | public function testLoadLocationByRemoteId() |
|
| 544 | { |
|
| 545 | $repository = $this->getRepository(); |
|
| 546 | ||
| 547 | /* BEGIN: Use Case */ |
|
| 548 | $locationService = $repository->getLocationService(); |
|
| 549 | ||
| 550 | $location = $locationService->loadLocationByRemoteId( |
|
| 551 | '3f6d92f8044aed134f32153517850f5a' |
|
| 552 | ); |
|
| 553 | /* END: Use Case */ |
|
| 554 | ||
| 555 | $this->assertEquals( |
|
| 556 | $locationService->loadLocation($this->generateId('location', 5)), |
|
| 557 | $location |
|
| 558 | ); |
|
| 559 | } |
|
| 560 | ||
| 561 | /** |
|
| 562 | * Test for the loadLocationByRemoteId() method. |
|
| @@ 130-147 (lines=18) @@ | ||
| 127 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 128 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 129 | */ |
|
| 130 | public function testLoadLocationThrowsUnauthorizedException() |
|
| 131 | { |
|
| 132 | $repository = $this->getRepository(); |
|
| 133 | ||
| 134 | $editorsGroupId = $this->generateId('group', 13); |
|
| 135 | ||
| 136 | /* BEGIN: Use Case */ |
|
| 137 | $locationService = $repository->getLocationService(); |
|
| 138 | ||
| 139 | $user = $this->createUserVersion1(); |
|
| 140 | ||
| 141 | // Set current user to newly created user |
|
| 142 | $repository->setCurrentUser($user); |
|
| 143 | ||
| 144 | // This call will fail with an "UnauthorizedException" |
|
| 145 | $locationService->loadLocation($editorsGroupId); |
|
| 146 | /* END: Use Case */ |
|
| 147 | } |
|
| 148 | ||
| 149 | /** |
|
| 150 | * Test for the loadLocationByRemoteId() method. |
|