public function testDeleteContentWithRollback() { $repository = $this->getRepositoryMock(); $repository->expects($this->once())->method('canUser')->with('content', 'remove')->will($this->returnValue(true)); $contentService = $this->getPartlyMockedContentService(array('internalLoadContentInfo')); /** @var \PHPUnit_Framework_MockObject_MockObject $locationHandler */ $locationHandler = $this->getPersistenceMock()->locationHandler(); $contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo'); $contentService->expects($this->once())->method('internalLoadContentInfo')->with(42)->will($this->returnValue($contentInfo)); $contentInfo->expects($this->any())->method('__get')->with('id')->will($this->returnValue(42)); $repository->expects($this->once())->method('beginTransaction'); $locationHandler->expects($this->once())->method('loadLocationsByContent')->with(42)->will($this->throwException(new \Exception())); $repository->expects($this->once())->method('rollback'); /* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */ $contentService->deleteContent($contentInfo); }