Permalink
Browse files

Merge remote-tracking branch 'upstream/6.13' into 7.2

  • Loading branch information...
ViniTou committed Oct 9, 2018
2 parents 8ef5093 + 9299c1b commit 50231ceab146e843952eedecc88d2b00397d7347
Showing with 65 additions and 2 deletions.
  1. +11 −2 Repository/Tests/BaseContentServiceTest.php
  2. +54 −0 Repository/Tests/ContentServiceTest.php
@@ -9,6 +9,7 @@
namespace eZ\Publish\API\Repository\Tests;
use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\API\Repository\Values\User\User;
/**
* Base class for content specific tests.
@@ -68,8 +69,12 @@ protected function createContentVersion1EmptyBinaryField()
*
* @return \eZ\Publish\API\Repository\Values\Content\Content
*/
protected function createContentDraftVersion1($locationId = 56, $contentTypeIdentifier = 'forum', $contentFieldNameIdentifier = 'name')
{
protected function createContentDraftVersion1(
$locationId = 56,
$contentTypeIdentifier = 'forum',
$contentFieldNameIdentifier = 'name',
User $contentOwner = null
) {
$repository = $this->getRepository();
$parentLocationId = $this->generateId('location', $locationId);
@@ -102,6 +107,10 @@ protected function createContentDraftVersion1($locationId = 56, $contentTypeIden
$contentCreate->sectionId = $sectionId;
$contentCreate->alwaysAvailable = true;
if ($contentOwner) {
$contentCreate->ownerId = $contentOwner->id;
}
// Create a draft
$draft = $contentService->createContent($contentCreate, array($locationCreate));
/* END: Inline */
@@ -3258,6 +3258,60 @@ public function testCopyContent()
);
}
/**
* Test for the copyContent() method with ezsettings.default.content.retain_owner_on_copy set to false
* See settings/test/integration_legacy.yml for service override.
*
* @see \eZ\Publish\API\Repository\ContentService::copyContent()
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft
* @group field-type
*/
public function testCopyContentWithNewOwner()
{
$parentLocationId = $this->generateId('location', 56);
$repository = $this->getRepository();
$contentService = $repository->getContentService();
$locationService = $repository->getLocationService();
$userService = $repository->getUserService();
$newOwner = $this->createUser('new_owner', 'foo', 'bar');
/* BEGIN: Use Case */
/** @var \eZ\Publish\API\Repository\Values\Content\Content $contentVersion2 */
$contentVersion2 = $this->createContentDraftVersion1(
$parentLocationId,
'forum',
'name',
$newOwner
);
// Configure new target location
$targetLocationCreate = $locationService->newLocationCreateStruct($parentLocationId);
$targetLocationCreate->priority = 42;
$targetLocationCreate->hidden = true;
$targetLocationCreate->remoteId = '01234abcdef5678901234abcdef56789';
$targetLocationCreate->sortField = Location::SORT_FIELD_NODE_ID;
$targetLocationCreate->sortOrder = Location::SORT_ORDER_DESC;
// Copy content with all versions and drafts
$contentCopied = $contentService->copyContent(
$contentVersion2->contentInfo,
$targetLocationCreate
);
/* END: Use Case */
$this->assertEquals(
$newOwner->id,
$contentVersion2->contentInfo->ownerId
);
$this->assertEquals(
$userService->loadUserByLogin('admin')->getUserId(),
$contentCopied->contentInfo->ownerId
);
}
/**
* Test for the copyContent() method.
*

0 comments on commit 50231ce

Please sign in to comment.