eZ\Publish\Core\Repository\Tests\Service\Mock\ContentTest::testCopyContentWithRollback PHP Method

testCopyContentWithRollback() public method

Test for the copyContent() method.
    public function testCopyContentWithRollback()
    {
        $repositoryMock = $this->getRepositoryMock();
        $contentService = $this->getPartlyMockedContentService();
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandlerMock */
        $contentHandlerMock = $this->getPersistenceMock()->contentHandler();
        $locationCreateStruct = new LocationCreateStruct();
        $contentInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo');
        $contentInfoMock->expects($this->any())->method('__get')->with('id')->will($this->returnValue(42));
        $this->mockGetDefaultObjectStates();
        $repositoryMock->expects($this->once())->method('beginTransaction');
        $repositoryMock->expects($this->once())->method('rollback');
        $repositoryMock->expects($this->once())->method('canUser')->with('content', 'create', $contentInfoMock, $locationCreateStruct)->will($this->returnValue(true));
        $contentHandlerMock->expects($this->once())->method('copy')->with(42, null)->will($this->throwException(new Exception('Handler threw an exception')));
        /* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfoMock */
        $contentService->copyContent($contentInfoMock, $locationCreateStruct, null);
    }
ContentTest