|
@@ 3201-3259 (lines=59) @@
|
| 3198 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
| 3199 |
|
* @group field-type |
| 3200 |
|
*/ |
| 3201 |
|
public function testCopyContent() |
| 3202 |
|
{ |
| 3203 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3204 |
|
|
| 3205 |
|
$repository = $this->getRepository(); |
| 3206 |
|
|
| 3207 |
|
$contentService = $repository->getContentService(); |
| 3208 |
|
$locationService = $repository->getLocationService(); |
| 3209 |
|
|
| 3210 |
|
/* BEGIN: Use Case */ |
| 3211 |
|
$contentVersion2 = $this->createMultipleLanguageContentVersion2(); |
| 3212 |
|
|
| 3213 |
|
// Configure new target location |
| 3214 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 3215 |
|
|
| 3216 |
|
$targetLocationCreate->priority = 42; |
| 3217 |
|
$targetLocationCreate->hidden = true; |
| 3218 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3219 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3220 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3221 |
|
|
| 3222 |
|
// Copy content with all versions and drafts |
| 3223 |
|
$contentCopied = $contentService->copyContent( |
| 3224 |
|
$contentVersion2->contentInfo, |
| 3225 |
|
$targetLocationCreate |
| 3226 |
|
); |
| 3227 |
|
/* END: Use Case */ |
| 3228 |
|
|
| 3229 |
|
$this->assertInstanceOf( |
| 3230 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
| 3231 |
|
$contentCopied |
| 3232 |
|
); |
| 3233 |
|
|
| 3234 |
|
$this->assertNotEquals( |
| 3235 |
|
$contentVersion2->contentInfo->remoteId, |
| 3236 |
|
$contentCopied->contentInfo->remoteId |
| 3237 |
|
); |
| 3238 |
|
|
| 3239 |
|
$this->assertNotEquals( |
| 3240 |
|
$contentVersion2->id, |
| 3241 |
|
$contentCopied->id |
| 3242 |
|
); |
| 3243 |
|
|
| 3244 |
|
$this->assertEquals( |
| 3245 |
|
2, |
| 3246 |
|
count($contentService->loadVersions($contentCopied->contentInfo)) |
| 3247 |
|
); |
| 3248 |
|
|
| 3249 |
|
$this->assertEquals(2, $contentCopied->getVersionInfo()->versionNo); |
| 3250 |
|
|
| 3251 |
|
$this->assertAllFieldsEquals($contentCopied->getFields()); |
| 3252 |
|
|
| 3253 |
|
$this->assertDefaultContentStates($contentCopied->contentInfo); |
| 3254 |
|
|
| 3255 |
|
$this->assertNotNull( |
| 3256 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3257 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3258 |
|
); |
| 3259 |
|
} |
| 3260 |
|
|
| 3261 |
|
/** |
| 3262 |
|
* Test for the copyContent() method. |
|
@@ 3269-3324 (lines=56) @@
|
| 3266 |
|
* |
| 3267 |
|
* @todo Fix to more descriptive name |
| 3268 |
|
*/ |
| 3269 |
|
public function testCopyContentWithThirdParameter() |
| 3270 |
|
{ |
| 3271 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3272 |
|
|
| 3273 |
|
$repository = $this->getRepository(); |
| 3274 |
|
|
| 3275 |
|
$contentService = $repository->getContentService(); |
| 3276 |
|
$locationService = $repository->getLocationService(); |
| 3277 |
|
|
| 3278 |
|
/* BEGIN: Use Case */ |
| 3279 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 3280 |
|
|
| 3281 |
|
// Configure new target location |
| 3282 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 3283 |
|
|
| 3284 |
|
$targetLocationCreate->priority = 42; |
| 3285 |
|
$targetLocationCreate->hidden = true; |
| 3286 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3287 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3288 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3289 |
|
|
| 3290 |
|
// Copy only the initial version |
| 3291 |
|
$contentCopied = $contentService->copyContent( |
| 3292 |
|
$contentVersion2->contentInfo, |
| 3293 |
|
$targetLocationCreate, |
| 3294 |
|
$contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 3295 |
|
); |
| 3296 |
|
/* END: Use Case */ |
| 3297 |
|
|
| 3298 |
|
$this->assertInstanceOf( |
| 3299 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
| 3300 |
|
$contentCopied |
| 3301 |
|
); |
| 3302 |
|
|
| 3303 |
|
$this->assertNotEquals( |
| 3304 |
|
$contentVersion2->contentInfo->remoteId, |
| 3305 |
|
$contentCopied->contentInfo->remoteId |
| 3306 |
|
); |
| 3307 |
|
|
| 3308 |
|
$this->assertNotEquals( |
| 3309 |
|
$contentVersion2->id, |
| 3310 |
|
$contentCopied->id |
| 3311 |
|
); |
| 3312 |
|
|
| 3313 |
|
$this->assertEquals( |
| 3314 |
|
1, |
| 3315 |
|
count($contentService->loadVersions($contentCopied->contentInfo)) |
| 3316 |
|
); |
| 3317 |
|
|
| 3318 |
|
$this->assertEquals(1, $contentCopied->getVersionInfo()->versionNo); |
| 3319 |
|
|
| 3320 |
|
$this->assertNotNull( |
| 3321 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3322 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3323 |
|
); |
| 3324 |
|
} |
| 3325 |
|
|
| 3326 |
|
/** |
| 3327 |
|
* Test for the addRelation() method. |