public function testDeletePolicyWithRollback()
{
$repository = $this->getRepositoryMock();
$roleServiceMock = $this->getPartlyMockedRoleService();
$policyMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Policy');
$policyMock->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('id', 42))));
$repository->expects($this->once())->method('hasAccess')->with($this->equalTo('role'), $this->equalTo('update'))->will($this->returnValue(true));
$repository->expects($this->once())->method('beginTransaction');
$userHandlerMock = $this->getPersistenceMockHandler('User\\Handler');
$userHandlerMock->expects($this->once())->method('deletePolicy')->with($this->equalTo(42))->will($this->throwException(new \Exception('Handler threw an exception')));
$repository->expects($this->once())->method('rollback');
/* @var \eZ\Publish\API\Repository\Values\User\Policy $policyMock */
$roleServiceMock->deletePolicy($policyMock);
}