public function testRemovePolicyWithRollback()
{
$repository = $this->getRepositoryMock();
$roleServiceMock = $this->getPartlyMockedRoleService();
$policyMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Policy');
$roleMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\Role');
$roleMock->expects($this->any())->method('__get')->with('id')->will($this->returnValue(24));
$policyMock->expects($this->any())->method('__get')->will($this->returnValueMap(array(array('id', 42), array('roleId', 24))));
$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\Role $roleMock */
/* @var \eZ\Publish\API\Repository\Values\User\Policy $policyMock */
$roleServiceMock->removePolicy($roleMock, $policyMock);
}