473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How can i test all scenarios of firstname and lastname

132 100+
I have this function i must test all scenarios of the firstname :
Expand|Select|Wrap|Line Numbers
  1. 1-first scenarios if the firstname is empty .
  2. 2-second scenarios if the firstname contains one character.
  3. 3-third scenrarios if the firstname have two character.
  4. 4-four scenarios if the firstname have Three character.
  5. 5-other scenarios ...
so here my function :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $loginuser = $thirdpartycode .'_'. substr($firstname, 0, 1) .''. substr($lastname, 0, 1);
  3. echo 'login user GeneratedLogin:'. $loginuser;
  4.  
  5. // $usercheck = new Admin_Model_DbTable_User();
  6. // $iduser=$usercheck->checkUser($loginuser);
  7.  
  8. $firstnamex = 0;
  9. $firstnamey = 1;
  10. $lastnamex = 0;
  11. $lastnamey = 1;
  12. $max = 4;
  13. do {
  14.     ++$firstnamey;
  15.     ++$lastnamey;
  16.     if (empty($firstname)) {
  17.         $loginuser = $thirdpartycode .'_'. substr($lastname, $lastnamex, $lastnamey);
  18.     }
  19.     else {
  20.         if (strlen($firstname) < $max) {
  21.             $firstnamex = 0;
  22.             $firstnamey = 1;
  23.             $loginuser = $thirdpartycode .'_'. substr($firstname, $firstnamex, $firstnamey) . '' . substr($lastname, $lastnamex, $lastnamey);
  24.         }
  25.  
  26.         $loginuser = $thirdpartycode .'_'. substr($firstname, $firstnamex, $firstnamey) . '' . substr($lastname, $lastnamex, $lastnamey);
  27.     }
  28.  
  29.     $usercheck = new Admin_Model_DbTable_User();
  30.     $iduser = $usercheck->checkUser($loginuser);
  31.     if (($firstnamey == $max) && ($lastnamey == $max)) break;
  32. }
  33.  
  34. while ($iduser > 0);
  35. error_log('login user GeneratedLogin:'. $loginuser);
  36. return $loginuser;
  37.  
  38.  
please can you my script and tell me what can i update to take all scenarios.
Sep 21 '15 #1
2 1184
Dormilich
8,658 Expert Mod 8TB
that’s what Unit Tests are for.

the most common library for that is PHPUnit.
Sep 22 '15 #2
manjava
132 100+
Thanks for your answer,but i need help about the scenarios if in the boucle while of the test the scenarios thanks in advance
Sep 22 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark 123 | last post by:
Hi I am getting an Object Expected error when using the following script. Can anyone see any syntax error? <script> aTemp=location.href.split("?");
5
by: Theresa Hancock via AccessMonster.com | last post by:
I have an Excel table I need to import into Access. The name is entered into one field "Name". I'd like to have two fields in Access, FirstName and LastName. How do I do this. -- Message posted...
2
by: musicloverlch | last post by:
I used to have a function that would change data that came across as LASTNAME, FIRSTNAME MI to FirstName M. LastName with an update query. Does that sould familar to anyone? Thanks in advance,...
3
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ...
4
by: pedalpete | last post by:
I've just loaded some code up to my testing machine, and I get nothing but "cannot modify header" errors. I don't get these errors on my dev machine at all. I've gone through my code, and all...
1
by: ramprakashjava | last post by:
hi , i hav this error while running this customerDetails.jsp <html:html> <head> <html:base/> </head> <body> <html:errors/> <html:form...
6
by: xavierDOTph | last post by:
i have a thesis about Alumni Directory of our School..Our problem is that how to filter members that have already have records on our database.. if he wants to join on the site he must fill in right...
10
by: pseudonymn | last post by:
Hello everyone, I am painfully new to Access and have absolutely no VBA knowledge. I've taken on the the burden of creating a database and up until now I've only used the expression creator or the...
5
by: praver235 | last post by:
Hi.. Following is the code i worked on to sort the lastnames.I need to know how to append firstname along with middlename to respective lastname. What I need to do to get the specified output?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.