473,549 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i test all scenarios of firstname and lastname

132 New Member
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 1197
Dormilich
8,658 Recognized Expert Moderator Expert
that’s what Unit Tests are for.

the most common library for that is PHPUnit.
Sep 22 '15 #2
manjava
132 New Member
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
4323
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
16586
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 via http://www.accessmonster.com
2
3799
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, Laura
3
7783
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ConnectionString="server=localhost;database=WordEngineering;Integrated Security=SSPI;" ProviderName="System.Data.OleDb"
4
1497
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 my the include which I believe is causing the error is one of the first things in the page, so that shouldn't be the issue. Is there anything else...
1
2664
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 action="/submitCustomerForm"> <bean:message key="prompt.customer.firstname"/>
6
1563
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 Firstname, Lastname, Course and Year..but the problem is that for example we could match like firstname LIKE '%fname%' AND lastname LIKE '%lname%' but...
10
6817
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 macro creator to add functionality to my forms. I understand this is a problem that was discussed here before but I really haven't been able to...
5
1378
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? Thanks. while ((s= in.readLine()) != null){ String names = s.split(" "); lastname = names; ...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.