| @@ 126-156 (lines=31) @@ | ||
| 123 | * |
|
| 124 | * @see \eZ\Publish\API\Repository\SectionService::loadSections() |
|
| 125 | */ |
|
| 126 | public function testLoadSectionsLoadsEmptyListForAnonymousUser() |
|
| 127 | { |
|
| 128 | $repository = $this->getRepository(); |
|
| 129 | ||
| 130 | $anonymousUserId = $this->generateId('user', 10); |
|
| 131 | /* BEGIN: Use Case */ |
|
| 132 | // $anonymousUserId is the ID of the "Anonymous" user in a eZ |
|
| 133 | // Publish demo installation. |
|
| 134 | $userService = $repository->getUserService(); |
|
| 135 | $sectionService = $repository->getSectionService(); |
|
| 136 | ||
| 137 | // Create some sections |
|
| 138 | $sectionCreateOne = $sectionService->newSectionCreateStruct(); |
|
| 139 | $sectionCreateOne->name = 'Test section one'; |
|
| 140 | $sectionCreateOne->identifier = 'uniqueKeyOne'; |
|
| 141 | ||
| 142 | $sectionCreateTwo = $sectionService->newSectionCreateStruct(); |
|
| 143 | $sectionCreateTwo->name = 'Test section two'; |
|
| 144 | $sectionCreateTwo->identifier = 'uniqueKeyTwo'; |
|
| 145 | ||
| 146 | $sectionService->createSection($sectionCreateOne); |
|
| 147 | $sectionService->createSection($sectionCreateTwo); |
|
| 148 | ||
| 149 | // Set anonymous user |
|
| 150 | $repository->getPermissionResolver()->setCurrentUserReference($userService->loadUser($anonymousUserId)); |
|
| 151 | ||
| 152 | $sections = $sectionService->loadSections(); |
|
| 153 | /* END: Use Case */ |
|
| 154 | ||
| 155 | $this->assertEquals([], $sections); |
|
| 156 | } |
|
| 157 | ||
| 158 | /** |
|
| 159 | * Test for the loadSections() method. |
|
| @@ 1403-1426 (lines=24) @@ | ||
| 1400 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
|
| 1401 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1402 | */ |
|
| 1403 | public function testUpdateLocationTwice() |
|
| 1404 | { |
|
| 1405 | $repository = $this->getRepository(); |
|
| 1406 | $permissionResolver = $repository->getPermissionResolver(); |
|
| 1407 | ||
| 1408 | $locationId = $this->generateId('location', 5); |
|
| 1409 | /* BEGIN: Use Case */ |
|
| 1410 | $locationService = $repository->getLocationService(); |
|
| 1411 | $permissionResolver->setCurrentUserReference($repository->getUserService()->loadUser(14)); |
|
| 1412 | ||
| 1413 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1414 | ||
| 1415 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1416 | $updateStruct->priority = 42; |
|
| 1417 | ||
| 1418 | $updatedLocation = $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1419 | ||
| 1420 | // Repeated update with the same, unchanged struct |
|
| 1421 | $secondUpdatedLocation = $locationService->updateLocation($updatedLocation, $updateStruct); |
|
| 1422 | /* END: Use Case */ |
|
| 1423 | ||
| 1424 | $this->assertEquals($updatedLocation->priority, 42); |
|
| 1425 | $this->assertEquals($secondUpdatedLocation->priority, 42); |
|
| 1426 | } |
|
| 1427 | ||
| 1428 | /** |
|
| 1429 | * Test for the swapLocation() method. |
|