diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index f9667bfe5..aab52b39d 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -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')) { diff --git a/tests/php-unit-tests/unitary-tests/application/LoginWebPageTest.php b/tests/php-unit-tests/unitary-tests/application/LoginWebPageTest.php new file mode 100644 index 000000000..35d31be6b --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/application/LoginWebPageTest.php @@ -0,0 +1,42 @@ +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')); + } +}