protected function mockPublishVersion($publicationDate = null)
{
$domainMapperMock = $this->getDomainMapperMock();
$contentMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
/* @var \PHPUnit_Framework_MockObject_MockObject $contentHandlerMock */
$versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
$contentInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo');
$contentHandlerMock = $this->getPersistenceMock()->contentHandler();
$metadataUpdateStruct = new SPIMetadataUpdateStruct();
$contentMock->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('id', 42), array('contentInfo', $contentInfoMock))));
$contentMock->expects($this->any())->method('getVersionInfo')->will($this->returnValue($versionInfoMock));
$versionInfoMock->expects($this->any())->method('getContentInfo')->will($this->returnValue($contentInfoMock));
$contentInfoMock->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('alwaysAvailable', true), array('mainLanguageCode', 'eng-GB'))));
$currentTime = time();
if ($publicationDate === null && $versionInfoMock->versionNo === 1) {
$publicationDate = $currentTime;
}
// Account for 1 second of test execution time
$metadataUpdateStruct->publicationDate = $publicationDate;
$metadataUpdateStruct->modificationDate = $currentTime;
$metadataUpdateStruct2 = clone $metadataUpdateStruct;
++$metadataUpdateStruct2->publicationDate;
++$metadataUpdateStruct2->modificationDate;
$spiContent = new SPIContent();
$contentHandlerMock->expects($this->once())->method('publish')->with(42, 123, $this->logicalOr($metadataUpdateStruct, $metadataUpdateStruct2))->will($this->returnValue($spiContent));
$domainMapperMock->expects($this->once())->method('buildContentDomainObject')->with($spiContent)->will($this->returnValue($contentMock));
/* @var \eZ\Publish\API\Repository\Values\Content\Content $contentMock */
$this->mockPublishUrlAliasesForContent($contentMock);
return $contentMock;
}