Php 如何测试firstname和lastname的所有场景
我有这个功能,我必须测试firstname的所有场景:Php 如何测试firstname和lastname的所有场景,php,Php,我有这个功能,我必须测试firstname的所有场景: 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-ot
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 ...
因此,这里是我的函数:
<?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;
你所说的“所有场景”是什么意思?你上一个场景中的名字有多长?所有场景的第一个和第二个。。。。。。最后,名字的长度是16个字符,提前谢谢