|
@@ 3123-3176 (lines=54) @@
|
| 3120 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
| 3121 |
|
* @group field-type |
| 3122 |
|
*/ |
| 3123 |
|
public function testCopyContent() |
| 3124 |
|
{ |
| 3125 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3126 |
|
|
| 3127 |
|
/* BEGIN: Use Case */ |
| 3128 |
|
$contentVersion2 = $this->createMultipleLanguageContentVersion2(); |
| 3129 |
|
|
| 3130 |
|
// Configure new target location |
| 3131 |
|
$targetLocationCreate = $this->locationService->newLocationCreateStruct($parentLocationId); |
| 3132 |
|
|
| 3133 |
|
$targetLocationCreate->priority = 42; |
| 3134 |
|
$targetLocationCreate->hidden = true; |
| 3135 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3136 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3137 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3138 |
|
|
| 3139 |
|
// Copy content with all versions and drafts |
| 3140 |
|
$contentCopied = $this->contentService->copyContent( |
| 3141 |
|
$contentVersion2->contentInfo, |
| 3142 |
|
$targetLocationCreate |
| 3143 |
|
); |
| 3144 |
|
/* END: Use Case */ |
| 3145 |
|
|
| 3146 |
|
$this->assertInstanceOf( |
| 3147 |
|
Content::class, |
| 3148 |
|
$contentCopied |
| 3149 |
|
); |
| 3150 |
|
|
| 3151 |
|
$this->assertNotEquals( |
| 3152 |
|
$contentVersion2->contentInfo->remoteId, |
| 3153 |
|
$contentCopied->contentInfo->remoteId |
| 3154 |
|
); |
| 3155 |
|
|
| 3156 |
|
$this->assertNotEquals( |
| 3157 |
|
$contentVersion2->id, |
| 3158 |
|
$contentCopied->id |
| 3159 |
|
); |
| 3160 |
|
|
| 3161 |
|
$this->assertEquals( |
| 3162 |
|
2, |
| 3163 |
|
count($this->contentService->loadVersions($contentCopied->contentInfo)) |
| 3164 |
|
); |
| 3165 |
|
|
| 3166 |
|
$this->assertEquals(2, $contentCopied->getVersionInfo()->versionNo); |
| 3167 |
|
|
| 3168 |
|
$this->assertAllFieldsEquals($contentCopied->getFields()); |
| 3169 |
|
|
| 3170 |
|
$this->assertDefaultContentStates($contentCopied->contentInfo); |
| 3171 |
|
|
| 3172 |
|
$this->assertNotNull( |
| 3173 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3174 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3175 |
|
); |
| 3176 |
|
} |
| 3177 |
|
|
| 3178 |
|
/** |
| 3179 |
|
* Test for the copyContent() method with ezsettings.default.content.retain_owner_on_copy set to false |
|
@@ 3234-3284 (lines=51) @@
|
| 3231 |
|
* @see \eZ\Publish\API\Repository\ContentService::copyContent($contentInfo, $destinationLocationCreateStruct, $versionInfo) |
| 3232 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testCopyContent |
| 3233 |
|
*/ |
| 3234 |
|
public function testCopyContentWithGivenVersion() |
| 3235 |
|
{ |
| 3236 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3237 |
|
|
| 3238 |
|
/* BEGIN: Use Case */ |
| 3239 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 3240 |
|
|
| 3241 |
|
// Configure new target location |
| 3242 |
|
$targetLocationCreate = $this->locationService->newLocationCreateStruct($parentLocationId); |
| 3243 |
|
|
| 3244 |
|
$targetLocationCreate->priority = 42; |
| 3245 |
|
$targetLocationCreate->hidden = true; |
| 3246 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3247 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3248 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3249 |
|
|
| 3250 |
|
// Copy only the initial version |
| 3251 |
|
$contentCopied = $this->contentService->copyContent( |
| 3252 |
|
$contentVersion2->contentInfo, |
| 3253 |
|
$targetLocationCreate, |
| 3254 |
|
$this->contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 3255 |
|
); |
| 3256 |
|
/* END: Use Case */ |
| 3257 |
|
|
| 3258 |
|
$this->assertInstanceOf( |
| 3259 |
|
Content::class, |
| 3260 |
|
$contentCopied |
| 3261 |
|
); |
| 3262 |
|
|
| 3263 |
|
$this->assertNotEquals( |
| 3264 |
|
$contentVersion2->contentInfo->remoteId, |
| 3265 |
|
$contentCopied->contentInfo->remoteId |
| 3266 |
|
); |
| 3267 |
|
|
| 3268 |
|
$this->assertNotEquals( |
| 3269 |
|
$contentVersion2->id, |
| 3270 |
|
$contentCopied->id |
| 3271 |
|
); |
| 3272 |
|
|
| 3273 |
|
$this->assertEquals( |
| 3274 |
|
1, |
| 3275 |
|
count($this->contentService->loadVersions($contentCopied->contentInfo)) |
| 3276 |
|
); |
| 3277 |
|
|
| 3278 |
|
$this->assertEquals(1, $contentCopied->getVersionInfo()->versionNo); |
| 3279 |
|
|
| 3280 |
|
$this->assertNotNull( |
| 3281 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3282 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3283 |
|
); |
| 3284 |
|
} |
| 3285 |
|
|
| 3286 |
|
/** |
| 3287 |
|
* Test for the addRelation() method. |