|
21 | 21 | use eZ\Publish\API\Repository\Values\Content\Query;
|
22 | 22 | use eZ\Publish\API\Repository\Values\Content\Search\SearchHit;
|
23 | 23 | use eZ\Publish\API\Repository\Values\Content\URLAlias;
|
| 24 | +use eZ\Publish\Core\Repository\Values\Content\ContentUpdateStruct; |
24 | 25 |
|
25 | 26 | /**
|
26 | 27 | * Test case for operations in the LocationService using in memory storage.
|
@@ -2384,6 +2385,62 @@ public function testCopySubtreeWithAliases()
|
2384 | 2385 | $this->assertGeneratedAliases($urlAliasService, $expectedSubItemAliases);
|
2385 | 2386 | }
|
2386 | 2387 |
|
| 2388 | + /** |
| 2389 | + * @covers \eZ\Publish\API\Repository\LocationService::copySubtree |
| 2390 | + */ |
| 2391 | + public function testCopySubtreeWithTranslatedContent(): void |
| 2392 | + { |
| 2393 | + $repository = $this->getRepository(); |
| 2394 | + $contentService = $repository->getContentService(); |
| 2395 | + $contentTypeService = $repository->getContentTypeService(); |
| 2396 | + $locationService = $repository->getLocationService(); |
| 2397 | + $urlAliasService = $repository->getURLAliasService(); |
| 2398 | + |
| 2399 | + $mediaLocationId = $this->generateId('location', 43); |
| 2400 | + $filesLocationId = $this->generateId('location', 52); |
| 2401 | + $demoDesignLocationId = $this->generateId('location', 56); |
| 2402 | + |
| 2403 | + $locationToCopy = $locationService->loadLocation($mediaLocationId); |
| 2404 | + $filesLocation = $locationService->loadLocation($filesLocationId); |
| 2405 | + $newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2406 | + |
| 2407 | + // translating the 'middle' folder |
| 2408 | + $translatedDraft = $contentService->createContentDraft($filesLocation->contentInfo); |
| 2409 | + $contentUpdateStruct = new ContentUpdateStruct([ |
| 2410 | + 'initialLanguageCode' => 'ger-DE', |
| 2411 | + 'fields' => $translatedDraft->getFields(), |
| 2412 | + ]); |
| 2413 | + $contentUpdateStruct->setField('short_name', 'FilesGER', 'ger-DE'); |
| 2414 | + $translatedContent = $contentService->updateContent($translatedDraft->versionInfo, $contentUpdateStruct); |
| 2415 | + $contentService->publishVersion($translatedContent->versionInfo); |
| 2416 | + |
| 2417 | + // creating additional content under translated folder |
| 2418 | + $contentType = $contentTypeService->loadContentTypeByIdentifier('folder'); |
| 2419 | + $contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-GB'); |
| 2420 | + $contentCreate->setField('name', 'My folder'); |
| 2421 | + $content = $contentService->createContent( |
| 2422 | + $contentCreate, |
| 2423 | + [new LocationCreateStruct(['parentLocationId' => $filesLocationId])] |
| 2424 | + ); |
| 2425 | + $contentService->publishVersion($content->versionInfo); |
| 2426 | + |
| 2427 | + $expectedSubItemAliases = [ |
| 2428 | + '/Design/Plain-site/Media/Multimedia', |
| 2429 | + '/Design/Plain-site/Media/Images', |
| 2430 | + '/Design/Plain-site/Media/Files', |
| 2431 | + '/Design/Plain-site/Media/Files/my-folder', |
| 2432 | + ]; |
| 2433 | + |
| 2434 | + $this->assertAliasesBeforeCopy($urlAliasService, $expectedSubItemAliases); |
| 2435 | + |
| 2436 | + $locationService->copySubtree( |
| 2437 | + $locationToCopy, |
| 2438 | + $newParentLocation |
| 2439 | + ); |
| 2440 | + |
| 2441 | + $this->assertGeneratedAliases($urlAliasService, $expectedSubItemAliases); |
| 2442 | + } |
| 2443 | + |
2387 | 2444 | /**
|
2388 | 2445 | * Asserts that given Content has default ContentStates.
|
2389 | 2446 | *
|
|
0 commit comments