I have this function i must test all scenarios of the firstname :
so here my function :
please can you my script and tell me what can i update to take all scenarios.
Code:
1-first scenarios if the firstname is empty . 2-second scenarios if the firstname contains one character. 3-third scenrarios if the firstname have two character. 4-four scenarios if the firstname have Three character. 5-other scenarios ...
Code:
<?php
$loginuser = $thirdpartycode .'_'. substr($firstname, 0, 1) .''. substr($lastname, 0, 1);
echo 'login user GeneratedLogin:'. $loginuser;
// $usercheck = new Admin_Model_DbTable_User();
// $iduser=$usercheck->checkUser($loginuser);
$firstnamex = 0;
$firstnamey = 1;
$lastnamex = 0;
$lastnamey = 1;
$max = 4;
do {
++$firstnamey;
++$lastnamey;
if (empty($firstname)) {
$loginuser = $thirdpartycode .'_'. substr($lastname, $lastnamex, $lastnamey);
}
else {
if (strlen($firstname) < $max) {
$firstnamex = 0;
$firstnamey = 1;
$loginuser = $thirdpartycode .'_'. substr($firstname, $firstnamex, $firstnamey) . '' . substr($lastname, $lastnamex, $lastnamey);
}
$loginuser = $thirdpartycode .'_'. substr($firstname, $firstnamex, $firstnamey) . '' . substr($lastname, $lastnamex, $lastnamey);
}
$usercheck = new Admin_Model_DbTable_User();
$iduser = $usercheck->checkUser($loginuser);
if (($firstnamey == $max) && ($lastnamey == $max)) break;
}
while ($iduser > 0);
error_log('login user GeneratedLogin:'. $loginuser);
return $loginuser;
Comment