N°4354 N°6587 Add test to cover $oUser->Get('profile_list') VS security.hide_administrators config param

This commit is contained in:
Pierre Goiffon
2023-07-27 16:42:56 +02:00
parent 1682a85cc0
commit e5b6e2eb8c
2 changed files with 92 additions and 1 deletions

View File

@@ -27,8 +27,8 @@ namespace Combodo\iTop\Test\UnitTest;
*/
use ArchivedObjectException;
use CMDBSource;
use CMDBObject;
use CMDBSource;
use Contact;
use DBObject;
use DBObjectSet;
@@ -442,6 +442,35 @@ class ItopDataTestCase extends ItopTestCase
return $oUser;
}
/**
* @param string $sLogin
* @param int $iProfileId
*
* @return \UserLocal
* @throws Exception
*/
protected function CreateContactlessUser($sLogin, $iProfileId, $sPassword = null)
{
if (empty($sPassword)) {
$sPassword = $sLogin;
}
$oUserProfile = new URP_UserProfile();
$oUserProfile->Set('profileid', $iProfileId);
$oUserProfile->Set('reason', 'UNIT Tests');
$oSet = DBObjectSet::FromObject($oUserProfile);
/** @var \UserLocal $oUser */
$oUser = $this->createObject('UserLocal', array(
'login' => $sLogin,
'password' => $sPassword,
'language' => 'EN US',
'profile_list' => $oSet,
));
$this->debug("Created {$oUser->GetName()} ({$oUser->GetKey()})");
return $oUser;
}
/**
* @param \DBObject $oUser
* @param int $iProfileId