|
@@ 3157-3210 (lines=54) @@
|
| 3154 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
| 3155 |
|
* @group field-type |
| 3156 |
|
*/ |
| 3157 |
|
public function testCopyContent() |
| 3158 |
|
{ |
| 3159 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3160 |
|
|
| 3161 |
|
/* BEGIN: Use Case */ |
| 3162 |
|
$contentVersion2 = $this->createMultipleLanguageContentVersion2(); |
| 3163 |
|
|
| 3164 |
|
// Configure new target location |
| 3165 |
|
$targetLocationCreate = $this->locationService->newLocationCreateStruct($parentLocationId); |
| 3166 |
|
|
| 3167 |
|
$targetLocationCreate->priority = 42; |
| 3168 |
|
$targetLocationCreate->hidden = true; |
| 3169 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3170 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3171 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3172 |
|
|
| 3173 |
|
// Copy content with all versions and drafts |
| 3174 |
|
$contentCopied = $this->contentService->copyContent( |
| 3175 |
|
$contentVersion2->contentInfo, |
| 3176 |
|
$targetLocationCreate |
| 3177 |
|
); |
| 3178 |
|
/* END: Use Case */ |
| 3179 |
|
|
| 3180 |
|
$this->assertInstanceOf( |
| 3181 |
|
Content::class, |
| 3182 |
|
$contentCopied |
| 3183 |
|
); |
| 3184 |
|
|
| 3185 |
|
$this->assertNotEquals( |
| 3186 |
|
$contentVersion2->contentInfo->remoteId, |
| 3187 |
|
$contentCopied->contentInfo->remoteId |
| 3188 |
|
); |
| 3189 |
|
|
| 3190 |
|
$this->assertNotEquals( |
| 3191 |
|
$contentVersion2->id, |
| 3192 |
|
$contentCopied->id |
| 3193 |
|
); |
| 3194 |
|
|
| 3195 |
|
$this->assertEquals( |
| 3196 |
|
2, |
| 3197 |
|
count($this->contentService->loadVersions($contentCopied->contentInfo)) |
| 3198 |
|
); |
| 3199 |
|
|
| 3200 |
|
$this->assertEquals(2, $contentCopied->getVersionInfo()->versionNo); |
| 3201 |
|
|
| 3202 |
|
$this->assertAllFieldsEquals($contentCopied->getFields()); |
| 3203 |
|
|
| 3204 |
|
$this->assertDefaultContentStates($contentCopied->contentInfo); |
| 3205 |
|
|
| 3206 |
|
$this->assertNotNull( |
| 3207 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3208 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3209 |
|
); |
| 3210 |
|
} |
| 3211 |
|
|
| 3212 |
|
/** |
| 3213 |
|
* Test for the copyContent() method with ezsettings.default.content.retain_owner_on_copy set to false |
|
@@ 3268-3318 (lines=51) @@
|
| 3265 |
|
* @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo) |
| 3266 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
| 3267 |
|
*/ |
| 3268 |
|
public function testCopyContentWithGivenVersion() |
| 3269 |
|
{ |
| 3270 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3271 |
|
|
| 3272 |
|
/* BEGIN: Use Case */ |
| 3273 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 3274 |
|
|
| 3275 |
|
// Configure new target location |
| 3276 |
|
$targetLocationCreate = $this->locationService->newLocationCreateStruct($parentLocationId); |
| 3277 |
|
|
| 3278 |
|
$targetLocationCreate->priority = 42; |
| 3279 |
|
$targetLocationCreate->hidden = true; |
| 3280 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3281 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3282 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3283 |
|
|
| 3284 |
|
// Copy only the initial version |
| 3285 |
|
$contentCopied = $this->contentService->copyContent( |
| 3286 |
|
$contentVersion2->contentInfo, |
| 3287 |
|
$targetLocationCreate, |
| 3288 |
|
$this->contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 3289 |
|
); |
| 3290 |
|
/* END: Use Case */ |
| 3291 |
|
|
| 3292 |
|
$this->assertInstanceOf( |
| 3293 |
|
Content::class, |
| 3294 |
|
$contentCopied |
| 3295 |
|
); |
| 3296 |
|
|
| 3297 |
|
$this->assertNotEquals( |
| 3298 |
|
$contentVersion2->contentInfo->remoteId, |
| 3299 |
|
$contentCopied->contentInfo->remoteId |
| 3300 |
|
); |
| 3301 |
|
|
| 3302 |
|
$this->assertNotEquals( |
| 3303 |
|
$contentVersion2->id, |
| 3304 |
|
$contentCopied->id |
| 3305 |
|
); |
| 3306 |
|
|
| 3307 |
|
$this->assertEquals( |
| 3308 |
|
1, |
| 3309 |
|
count($this->contentService->loadVersions($contentCopied->contentInfo)) |
| 3310 |
|
); |
| 3311 |
|
|
| 3312 |
|
$this->assertEquals(1, $contentCopied->getVersionInfo()->versionNo); |
| 3313 |
|
|
| 3314 |
|
$this->assertNotNull( |
| 3315 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3316 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3317 |
|
); |
| 3318 |
|
} |
| 3319 |
|
|
| 3320 |
|
/** |
| 3321 |
|
* Test for the addRelation() method. |