|
@@ 3128-3186 (lines=59) @@
|
| 3125 |
|
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft |
| 3126 |
|
* @group field-type |
| 3127 |
|
*/ |
| 3128 |
|
public function testCopyContent() |
| 3129 |
|
{ |
| 3130 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3131 |
|
|
| 3132 |
|
$repository = $this->getRepository(); |
| 3133 |
|
|
| 3134 |
|
$contentService = $repository->getContentService(); |
| 3135 |
|
$locationService = $repository->getLocationService(); |
| 3136 |
|
|
| 3137 |
|
/* BEGIN: Use Case */ |
| 3138 |
|
$contentVersion2 = $this->createMultipleLanguageContentVersion2(); |
| 3139 |
|
|
| 3140 |
|
// Configure new target location |
| 3141 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 3142 |
|
|
| 3143 |
|
$targetLocationCreate->priority = 42; |
| 3144 |
|
$targetLocationCreate->hidden = true; |
| 3145 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3146 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3147 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3148 |
|
|
| 3149 |
|
// Copy content with all versions and drafts |
| 3150 |
|
$contentCopied = $contentService->copyContent( |
| 3151 |
|
$contentVersion2->contentInfo, |
| 3152 |
|
$targetLocationCreate |
| 3153 |
|
); |
| 3154 |
|
/* END: Use Case */ |
| 3155 |
|
|
| 3156 |
|
$this->assertInstanceOf( |
| 3157 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
| 3158 |
|
$contentCopied |
| 3159 |
|
); |
| 3160 |
|
|
| 3161 |
|
$this->assertNotEquals( |
| 3162 |
|
$contentVersion2->contentInfo->remoteId, |
| 3163 |
|
$contentCopied->contentInfo->remoteId |
| 3164 |
|
); |
| 3165 |
|
|
| 3166 |
|
$this->assertNotEquals( |
| 3167 |
|
$contentVersion2->id, |
| 3168 |
|
$contentCopied->id |
| 3169 |
|
); |
| 3170 |
|
|
| 3171 |
|
$this->assertEquals( |
| 3172 |
|
2, |
| 3173 |
|
count($contentService->loadVersions($contentCopied->contentInfo)) |
| 3174 |
|
); |
| 3175 |
|
|
| 3176 |
|
$this->assertEquals(2, $contentCopied->getVersionInfo()->versionNo); |
| 3177 |
|
|
| 3178 |
|
$this->assertAllFieldsEquals($contentCopied->getFields()); |
| 3179 |
|
|
| 3180 |
|
$this->assertDefaultContentStates($contentCopied->contentInfo); |
| 3181 |
|
|
| 3182 |
|
$this->assertNotNull( |
| 3183 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3184 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3185 |
|
); |
| 3186 |
|
} |
| 3187 |
|
|
| 3188 |
|
/** |
| 3189 |
|
* Test for the copyContent() method. |
|
@@ 3196-3251 (lines=56) @@
|
| 3193 |
|
* |
| 3194 |
|
* @todo Fix to more descriptive name |
| 3195 |
|
*/ |
| 3196 |
|
public function testCopyContentWithThirdParameter() |
| 3197 |
|
{ |
| 3198 |
|
$parentLocationId = $this->generateId('location', 56); |
| 3199 |
|
|
| 3200 |
|
$repository = $this->getRepository(); |
| 3201 |
|
|
| 3202 |
|
$contentService = $repository->getContentService(); |
| 3203 |
|
$locationService = $repository->getLocationService(); |
| 3204 |
|
|
| 3205 |
|
/* BEGIN: Use Case */ |
| 3206 |
|
$contentVersion2 = $this->createContentVersion2(); |
| 3207 |
|
|
| 3208 |
|
// Configure new target location |
| 3209 |
|
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 3210 |
|
|
| 3211 |
|
$targetLocationCreate->priority = 42; |
| 3212 |
|
$targetLocationCreate->hidden = true; |
| 3213 |
|
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789'; |
| 3214 |
|
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 3215 |
|
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 3216 |
|
|
| 3217 |
|
// Copy only the initial version |
| 3218 |
|
$contentCopied = $contentService->copyContent( |
| 3219 |
|
$contentVersion2->contentInfo, |
| 3220 |
|
$targetLocationCreate, |
| 3221 |
|
$contentService->loadVersionInfo($contentVersion2->contentInfo, 1) |
| 3222 |
|
); |
| 3223 |
|
/* END: Use Case */ |
| 3224 |
|
|
| 3225 |
|
$this->assertInstanceOf( |
| 3226 |
|
'\\eZ\\Publish\\API\\Repository\\Values\\Content\\Content', |
| 3227 |
|
$contentCopied |
| 3228 |
|
); |
| 3229 |
|
|
| 3230 |
|
$this->assertNotEquals( |
| 3231 |
|
$contentVersion2->contentInfo->remoteId, |
| 3232 |
|
$contentCopied->contentInfo->remoteId |
| 3233 |
|
); |
| 3234 |
|
|
| 3235 |
|
$this->assertNotEquals( |
| 3236 |
|
$contentVersion2->id, |
| 3237 |
|
$contentCopied->id |
| 3238 |
|
); |
| 3239 |
|
|
| 3240 |
|
$this->assertEquals( |
| 3241 |
|
1, |
| 3242 |
|
count($contentService->loadVersions($contentCopied->contentInfo)) |
| 3243 |
|
); |
| 3244 |
|
|
| 3245 |
|
$this->assertEquals(1, $contentCopied->getVersionInfo()->versionNo); |
| 3246 |
|
|
| 3247 |
|
$this->assertNotNull( |
| 3248 |
|
$contentCopied->contentInfo->mainLocationId, |
| 3249 |
|
'Expected main location to be set given we provided a LocationCreateStruct' |
| 3250 |
|
); |
| 3251 |
|
} |
| 3252 |
|
|
| 3253 |
|
/** |
| 3254 |
|
* Test for the addRelation() method. |