Guest User

Untitled

a guest
Mar 8th, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. @IsTest static void testRegFormWithNewUserAddress11() {
  2.  
  3. Contact con = new Contact();
  4.  
  5. con.Firstname = 'test';
  6.  
  7. con.LastName ='test';
  8.  
  9. con.OtherPhone = '8765432167';
  10.  
  11. con.Organization_Type__c = 'test';
  12.  
  13. con.Email ='Sitetestg466@hotmail.com';
  14.  
  15. insert con;
  16.  
  17. Order__c ordr = new Order__c();
  18.  
  19. ordr.Contact__c = con.Id;
  20.  
  21. ordr.Account__c = a.Id;
  22.  
  23. insert ordr;
  24.  
  25. Order_Line__c ordrline = new Order_Line__c();
  26. ordrline.Order__c = ordr.id;
  27.  
  28. insert ordrline;
  29.  
  30.  
  31. ControllerTest controller = new ControllerTest();
  32.  
  33. controller.con = con;
  34.  
  35. controller.acc = a;
  36.  
  37. controller.Password= 'testpass123';
  38.  
  39. controller.checkIfContactExists();
  40.  
  41. controller.checkIfAccountExists();
  42.  
  43. controller.setTab();
  44.  
  45. Profile p = [select Name, id From Profile where UserLicense.Name like '%Customer Community%' limit 1];
  46.  
  47. User u = new User ();
  48.  
  49. u.FirstName = 'test';
  50. u.LastName ='test';
  51.  
  52. u.Email ='testemail'+Math.round(Math.random()*Math.pow(10, 7))+'@testemail.com';
  53.  
  54. u.Username = 'testemail'+Math.round(Math.random()*Math.pow(10, 8))+'@testemai.com';
  55. u.Alias ='test';
  56. u.CommunityNickname ='tst';
  57. u.ContactId =con.Id;
  58. u.LanguageLocaleKey = 'en_US';
  59. u.LocaleSidKey ='en_CA';
  60. u.TimeZoneSidKey ='America/Chicago';
  61.  
  62. u.ProfileId = p.Id;
  63.  
  64. u.EmailEncodingKey = 'UTF-8';
  65. insert u;
  66.  
  67. }
  68.  
  69. List<User> existalready = [select id,Contact.FirstName,Username,Contact.LastName from user where username =:Email and IsActive = true LIMIT 1];
  70. if(existalready.size()<0){
  71.  
  72. for(User u: existalready){
  73. insert u ;
  74. insert con;
Add Comment
Please, Sign In to add comment