|
@@ 1141-1182 (lines=42) @@
|
| 1138 |
|
* @see \eZ\Publish\API\Repository\ContentService::copyContent() |
| 1139 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
| 1140 |
|
*/ |
| 1141 |
|
public function testCopyContentThrowsUnauthorizedException() |
| 1142 |
|
{ |
| 1143 |
|
$parentLocationId = $this->generateId('location', 52); |
| 1144 |
|
|
| 1145 |
|
$repository = $this->getRepository(); |
| 1146 |
|
|
| 1147 |
|
$contentService = $repository->getContentService(); |
| 1148 |
|
$locationService = $repository->getLocationService(); |
| 1149 |
|
|
| 1150 |
|
$anonymousUserId = $this->generateId('user', 10); |
| 1151 |
|
/* BEGIN: Use Case */ |
| 1152 |
|
// $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
| 1153 |
|
// demo installation |
| 1154 |
|
$contentVersion2 = $this->createMultipleLanguageContentVersion2(); |
| 1155 |
|
|
| 1156 |
|
// Get ContentInfo instance of version 2 |
| 1157 |
|
$contentInfo = $contentVersion2->contentInfo; |
| 1158 |
|
|
| 1159 |
|
// Load the user service |
| 1160 |
|
$userService = $repository->getUserService(); |
| 1161 |
|
|
| 1162 |
|
// Set anonymous user |
| 1163 |
|
$repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
| 1164 |
|
|
| 1165 |
|
// Configure new target location |
| 1166 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 1167 |
|
|
| 1168 |
|
$targetLocationCreate->priority = 42; |
| 1169 |
|
$targetLocationCreate->hidden = true; |
| 1170 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 1171 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 1172 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 1173 |
|
|
| 1174 |
|
$this->expectException(UnauthorizedException::class); |
| 1175 |
|
$this->expectExceptionMessageRegExp('/\'read\' \'content\'/'); |
| 1176 |
|
|
| 1177 |
|
$contentService->copyContent( |
| 1178 |
|
$contentInfo, |
| 1179 |
|
$targetLocationCreate |
| 1180 |
|
); |
| 1181 |
|
/* END: Use Case */ |
| 1182 |
|
} |
| 1183 |
|
|
| 1184 |
|
/** |
| 1185 |
|
* Test for the copyContent() method. |
|
@@ 1190-1229 (lines=40) @@
|
| 1187 |
|
* @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo) |
| 1188 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContentWithGivenVersion |
| 1189 |
|
*/ |
| 1190 |
|
public function testCopyContentThrowsUnauthorizedExceptionWithGivenVersion() |
| 1191 |
|
{ |
| 1192 |
|
$parentLocationId = $this->generateId('location', 52); |
| 1193 |
|
|
| 1194 |
|
$repository = $this->getRepository(); |
| 1195 |
|
|
| 1196 |
|
$contentService = $repository->getContentService(); |
| 1197 |
|
$locationService = $repository->getLocationService(); |
| 1198 |
|
|
| 1199 |
|
$anonymousUserId = $this->generateId('user', 10); |
| 1200 |
|
/* BEGIN: Use Case */ |
| 1201 |
|
// $anonymousUserId is the ID of the "Anonymous User" in an eZ Publish |
| 1202 |
|
// demo installation |
| 1203 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 1204 |
|
|
| 1205 |
|
// Load the user service |
| 1206 |
|
$userService = $repository->getUserService(); |
| 1207 |
|
|
| 1208 |
|
// Set anonymous user |
| 1209 |
|
$repository->setCurrentUser($userService->loadUser($anonymousUserId)); |
| 1210 |
|
|
| 1211 |
|
// Configure new target location |
| 1212 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 1213 |
|
|
| 1214 |
|
$targetLocationCreate->priority = 42; |
| 1215 |
|
$targetLocationCreate->hidden = true; |
| 1216 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 1217 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 1218 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 1219 |
|
|
| 1220 |
|
$this->expectException(UnauthorizedException::class); |
| 1221 |
|
$this->expectExceptionMessageRegExp('/\'versionread\' \'content\'/'); |
| 1222 |
|
|
| 1223 |
|
$contentService->copyContent( |
| 1224 |
|
$contentVersion2->contentInfo, |
| 1225 |
|
$targetLocationCreate, |
| 1226 |
|
$contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 1227 |
|
); |
| 1228 |
|
/* END: Use Case */ |
| 1229 |
|
} |
| 1230 |
|
|
| 1231 |
|
/** |
| 1232 |
|
* Test for the loadRelations() method. |