public function testCopyContent() { $repositoryMock = $this->getRepositoryMock(); $contentService = $this->getPartlyMockedContentService(array('internalLoadContentInfo', 'internalLoadContent')); $locationServiceMock = $this->getLocationServiceMock(); $contentInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo'); $locationCreateStruct = new LocationCreateStruct(); $repositoryMock->expects($this->exactly(2))->method('getLocationService')->will($this->returnValue($locationServiceMock)); $contentInfoMock->expects($this->any())->method('__get')->with('id')->will($this->returnValue(42)); $versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo'); $versionInfoMock->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('versionNo', 123), array('status', VersionInfo::STATUS_DRAFT)))); $versionInfoMock->expects($this->once())->method('getContentInfo')->will($this->returnValue($contentInfoMock)); /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandlerMock */ $contentHandlerMock = $this->getPersistenceMock()->contentHandler(); $domainMapperMock = $this->getDomainMapperMock(); $repositoryMock->expects($this->once())->method('beginTransaction'); $repositoryMock->expects($this->once())->method('commit'); $repositoryMock->expects($this->once())->method('canUser')->with('content', 'create', $contentInfoMock, $locationCreateStruct)->will($this->returnValue(true)); $spiContentInfo = new SPIContentInfo(array('id' => 42)); $spiVersionInfo = new SPIVersionInfo(array('contentInfo' => $spiContentInfo, 'creationDate' => 123456)); $spiContent = new SPIContent(array('versionInfo' => $spiVersionInfo)); $contentHandlerMock->expects($this->once())->method('copy')->with(42, null)->will($this->returnValue($spiContent)); $this->mockGetDefaultObjectStates(); $this->mockSetDefaultObjectStates(); $domainMapperMock->expects($this->once())->method('buildVersionInfoDomainObject')->with($spiVersionInfo)->will($this->returnValue($versionInfoMock)); /* @var \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfoMock */ $content = $this->mockPublishVersion(123456); $locationServiceMock->expects($this->once())->method('createLocation')->with($content->getVersionInfo()->getContentInfo(), $locationCreateStruct); $contentService->expects($this->once())->method('internalLoadContent')->with($content->id)->will($this->returnValue($content)); /* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfoMock */ $contentService->copyContent($contentInfoMock, $locationCreateStruct, null); }