6912- add test

This commit is contained in:
odain
2023-11-03 14:31:19 +01:00
parent 3eee03d504
commit e844b4c3ce
2 changed files with 43 additions and 1 deletions

View File

@@ -872,7 +872,7 @@ class LoginWebPage extends NiceWebPage
*
* @return \UserExternal|null
*/
public static function ProvisionUser(string$sAuthUser, ?Person $oPerson, array $aRequestedProfiles)
public static function ProvisionUser(string $sAuthUser, ?Person $oPerson, array $aRequestedProfiles)
{
if (!MetaModel::IsValidClass('URP_Profiles'))
{

View File

@@ -0,0 +1,42 @@
<?php
namespace Combodo\iTop\Test\UnitTest\Application;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
/**
* @covers LoginWebPage
*/
class LoginWebPageTest extends ItopDataTestCase
{
public function testProvisionUserOnly(){
$iNum = uniqid();
$sEmail = "ProvisionUser".$iNum . "@gabuzomeu.shadok";
$oUser = \LoginWebPage::ProvisionUser($sEmail, null, [ 'Portal User']);
$this->assertNotNull($oUser);
$oUser = \MetaModel::GetObject(\UserExternal::class, $oUser->GetKey());
$this->assertNotNull($oUser);
$this->assertEquals($sEmail, $oUser->Get('login'));
$this->assertEquals(\MetaModel::GetConfig()->GetDefaultLanguage(), $oUser->Get('language'));
$this->assertEquals(0, $oUser->Get('contactid'));
}
public function testProvisionUserWithPerson(){
$iNum = uniqid();
$this->CreateTestOrganization();
$oPerson = $this->CreatePerson($iNum);
$sEmail = "ProvisionUser".$iNum . "@gabuzomeu.shadok";
$oUser = \LoginWebPage::ProvisionUser($sEmail, $oPerson, [ 'Portal User']);
$this->assertNotNull($oUser);
$oUser = \MetaModel::GetObject(\UserExternal::class, $oUser->GetKey());
$this->assertNotNull($oUser);
$this->assertEquals($sEmail, $oUser->Get('login'));
$this->assertEquals(\MetaModel::GetConfig()->GetDefaultLanguage(), $oUser->Get('language'));
$this->assertEquals($oPerson->GetKey(), $oUser->Get('contactid'));
}
}