Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Oct 9, 2018
2 parents 77f32ee + 50231ce commit 3d85b6f
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Repository/Tests/BaseContentServiceTest.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down
54 changes: 54 additions & 0 deletions Repository/Tests/ContentServiceTest.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit 3d85b6f

Please sign in to comment.