|
@@ 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 with ezsettings.default.content.retain_owner_on_copy set to false |
|
@@ 3323-3378 (lines=56) @@
|
| 3320 |
|
* |
| 3321 |
|
* @todo Fix to more descriptive name |
| 3322 |
|
*/ |
| 3323 |
|
public function testCopyContentWithThirdParameter() |
| 3324 |
|
{ |
| 3325 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3326 |
|
|
| 3327 |
|
$repository = $this->getRepository(); |
| 3328 |
|
|
| 3329 |
|
$contentService = $repository->getContentService(); |
| 3330 |
|
$locationService = $repository->getLocationService(); |
| 3331 |
|
|
| 3332 |
|
/* BEGIN: Use Case */ |
| 3333 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 3334 |
|
|
| 3335 |
|
// Configure new target location |
| 3336 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 3337 |
|
|
| 3338 |
|
$targetLocationCreate->priority = 42; |
| 3339 |
|
$targetLocationCreate->hidden = true; |
| 3340 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3341 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3342 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3343 |
|
|
| 3344 |
|
// Copy only the initial version |
| 3345 |
|
$contentCopied = $contentService->copyContent( |
| 3346 |
|
$contentVersion2->contentInfo, |
| 3347 |
|
$targetLocationCreate, |
| 3348 |
|
$contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 3349 |
|
); |
| 3350 |
|
/* END: Use Case */ |
| 3351 |
|
|
| 3352 |
|
$this->assertInstanceOf( |
| 3353 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
| 3354 |
|
$contentCopied |
| 3355 |
|
); |
| 3356 |
|
|
| 3357 |
|
$this->assertNotEquals( |
| 3358 |
|
$contentVersion2->contentInfo->remoteId, |
| 3359 |
|
$contentCopied->contentInfo->remoteId |
| 3360 |
|
); |
| 3361 |
|
|
| 3362 |
|
$this->assertNotEquals( |
| 3363 |
|
$contentVersion2->id, |
| 3364 |
|
$contentCopied->id |
| 3365 |
|
); |
| 3366 |
|
|
| 3367 |
|
$this->assertEquals( |
| 3368 |
|
1, |
| 3369 |
|
count($contentService->loadVersions($contentCopied->contentInfo)) |
| 3370 |
|
); |
| 3371 |
|
|
| 3372 |
|
$this->assertEquals(1, $contentCopied->getVersionInfo()->versionNo); |
| 3373 |
|
|
| 3374 |
|
$this->assertNotNull( |
| 3375 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3376 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3377 |
|
); |
| 3378 |
|
} |
| 3379 |
|
|
| 3380 |
|
/** |
| 3381 |
|
* Test for the addRelation() method. |