示例#1
0
 public function testConvertAccountCopied()
 {
     //there will be output from display function, so call ob_start to trap it
     ob_start();
     $_POST = array();
     //set the request parameters and convert the lead
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $this->lead->id;
     $_REQUEST['handle'] = 'save';
     $_REQUEST['selectedAccount'] = $this->account->id;
     //require view and call display class so that convert functionality is called
     require_once 'modules/Leads/views/view.convertlead.php';
     $vc = new ViewConvertLead();
     $vc->display();
     //retrieve the lead again to make sure we have the latest converted lead in memory
     $this->lead->retrieve($this->lead->id);
     //retrieve the new contact id from the conversion
     $contact_id = $this->lead->contact_id;
     //throw error if contact id was not retrieved and exit test
     $this->assertTrue(!empty($contact_id), "contact id was not created during conversion process.  An error has ocurred, aborting rest of test.");
     if (empty($contact_id)) {
         return;
     }
     //make sure the new contact has the account related and that it matches the lead account
     $this->contact->retrieve($contact_id);
     $this->assertTrue($this->contact->account_id == $this->lead->account_id, "Account id from converted lead does not match the new contact account id, there was an error during conversion.");
     $output = ob_get_clean();
 }
示例#2
0
 /**
  * Create a lead and convert it to an existing Account and Contact
  */
 public function testConvertLinkingExistingContact()
 {
     // Create records
     $lead = SugarTestLeadUtilities::createLead();
     $account = SugarTestAccountUtilities::createAccount();
     $contact = SugarTestContactUtilities::createContact();
     // ConvertLead to an existing Contact and Account
     $_REQUEST = array('module' => 'Leads', 'record' => $lead->id, 'isDuplicate' => 'false', 'action' => 'ConvertLead', 'convert_create_Contacts' => 'false', 'report_to_name' => $contact->name, 'reports_to_id' => $contact->id, 'convert_create_Accounts' => 'false', 'account_name' => $account->name, 'account_id' => $account->id, 'handle' => 'save');
     // Call display to trigger conversion
     $vc = new ViewConvertLead();
     $vc->display();
     // Refresh Lead
     $leadId = $lead->id;
     $lead = new Lead();
     $lead->retrieve($leadId);
     // Refresh Contact
     $contactId = $contact->id;
     $contact = new Contact();
     $contact->retrieve($contactId);
     // Check if contact it's linked properly
     $this->assertEquals($contact->id, $lead->contact_id, 'Contact not linked with Lead successfully.');
     // Check if account is linked with lead properly
     $this->assertEquals($account->id, $lead->account_id, 'Account not linked with Lead successfully.');
     // Check if account is linked with contact properly
     $this->assertEquals($account->id, $contact->account_id, 'Account not linked with Contact successfully.');
     // Check Lead Status, should be converted
     $this->assertEquals('Converted', $lead->status, "Lead status should be 'Converted'.");
 }
 /**
  * @group bug45187
  */
 public function testActivityModuleLabel()
 {
     global $sugar_config;
     global $app_list_strings;
     // init
     $lead = SugarTestLeadUtilities::createLead();
     $account = SugarTestAccountUtilities::createAccount();
     // simulate module renaming
     $org_name = $app_list_strings['moduleListSingular']['Contacts'];
     $app_list_strings['moduleListSingular']['Contacts'] = 'People';
     // set the request/post parameters before converting the lead
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $lead->id;
     unset($_REQUEST['handle']);
     $_REQUEST['selectedAccount'] = $account->id;
     $sugar_config['lead_conv_activity_opt'] = 'move';
     // call display to trigger conversion
     $vc = new ViewConvertLead();
     $vc->init($lead);
     $vc->display();
     // the activity options dropdown should use the renamed module label
     $this->expectOutputRegex('/.*People<\\/OPTION>.*/');
     // cleanup
     $app_list_strings['moduleListSingular']['Contacts'] = $org_name;
     unset($_REQUEST['module']);
     unset($_REQUEST['action']);
     unset($_REQUEST['record']);
     unset($_REQUEST['selectedAccount']);
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }
示例#4
0
 public function testConvertContactInCampaignLog()
 {
     //there will be output from display function, so call ob_start to trap it
     ob_start();
     $_POST = array();
     //set the request parameters and convert the lead
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $this->lead->id;
     $_REQUEST['handle'] = 'save';
     $_REQUEST['selectedAccount'] = $this->account->id;
     //require view and call display class so that convert functionality is called
     require_once 'modules/Leads/views/view.convertlead.php';
     $vc = new ViewConvertLead();
     $vc->display();
     //retrieve the lead again to make sure we have the latest converted lead in memory
     $this->lead->retrieve($this->lead->id);
     //retrieve the new contact id from the conversion
     $contact_id = $this->lead->contact_id;
     //throw error if contact id was not retrieved and exit test
     $this->assertTrue(!empty($contact_id), "contact id was not created during conversion process.  An error has ocurred, aborting rest of test.");
     if (empty($contact_id)) {
         return;
     }
     //make sure the new contact has the account related and that it matches the lead account
     $query = "SELECT target_id FROM campaign_log WHERE campaign_id= '{$this->campaign->id}'";
     $result = $GLOBALS['db']->query($query);
     while ($row = $GLOBALS['db']->fetchByAssoc($result)) {
         $test_contact_id = $row['target_id'];
     }
     $this->assertEquals($contact_id, $test_contact_id);
     $output = ob_get_clean();
 }
示例#5
0
 public function testConversionAndDoNothing()
 {
     global $sugar_config;
     // init
     $lead = SugarTestLeadUtilities::createLead();
     $account = SugarTestAccountUtilities::createAccount();
     $meeting = SugarTestMeetingUtilities::createMeeting();
     SugarTestMeetingUtilities::addMeetingParent($meeting->id, $lead->id);
     $relation_id = SugarTestMeetingUtilities::addMeetingLeadRelation($meeting->id, $lead->id);
     $_REQUEST['record'] = $lead->id;
     // set the request/post parameters before converting the lead
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $lead->id;
     $_REQUEST['handle'] = 'save';
     $_REQUEST['selectedAccount'] = $account->id;
     $sugar_config['lead_conv_activity_opt'] = 'none';
     // call display to trigger conversion
     $vc = new ViewConvertLead();
     $vc->display();
     // refresh meeting
     $meeting_id = $meeting->id;
     $meeting = new Meeting();
     $meeting->retrieve($meeting_id);
     // refresh lead
     $lead_id = $lead->id;
     $lead = new Lead();
     $lead->retrieve($lead_id);
     // retrieve the new contact id from the conversion
     $contact_id = $lead->contact_id;
     // 1. Lead's contact_id should not be null
     $this->assertNotNull($contact_id, 'Lead has null contact id after conversion.');
     // 2. Lead status should be 'Converted'
     $this->assertEquals('Converted', $lead->status, "Lead atatus should be 'Converted'.");
     // 3. parent_type of the original meeting should be Leads
     $this->assertEquals('Leads', $meeting->parent_type, 'Meeting parent should be Leads');
     // 4. parent_id of the original meeting should be contact id
     $this->assertEquals($lead_id, $meeting->parent_id, 'Meeting parent id should be lead id.');
     // 5. record should NOT be deleted from meetings_leads table
     $sql = "select id from meetings_leads where meeting_id='{$meeting->id}' and lead_id='{$lead->id}' and deleted=0";
     $result = $GLOBALS['db']->query($sql);
     $row = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertFalse(empty($row), "Meeting-Lead relationship is removed.");
     // 6. record should NOT be added to meetings_contacts table
     $sql = "select meeting_id from meetings_contacts where contact_id='{$contact_id}' and deleted=0";
     $result = $GLOBALS['db']->query($sql);
     $row = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertFalse($row, "Meeting-Contact relationship should not be added.");
     // clean up
     unset($_REQUEST['record']);
     $GLOBALS['db']->query("delete from meetings where parent_id='{$lead->id}' and parent_type= 'Leads'");
     $GLOBALS['db']->query("delete from meetings where parent_id='{$contact_id}' and parent_type= 'Contacts'");
     $GLOBALS['db']->query("delete from contacts where id='{$contact_id}'");
     $GLOBALS['db']->query("delete from meetings_leads where meeting_id='{$meeting->id}' and lead_id= '{$lead_id}'");
     $GLOBALS['db']->query("delete from meetings_contacts where contact_id= '{$contact_id}'");
     SugarTestMeetingUtilities::deleteMeetingLeadRelation($relation_id);
     SugarTestMeetingUtilities::removeMeetingContacts();
     SugarTestMeetingUtilities::removeAllCreatedMeetings();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }
示例#6
0
 public function testConvertAccountCopied()
 {
     $_POST = array();
     //set the request parameters and convert the lead
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $this->lead->id;
     $_REQUEST['handle'] = 'save';
     $_REQUEST['selectedAccount'] = $this->account->id;
     // Create a Contact
     $_REQUEST['convert_create_Contacts'] = 'true';
     // $_POST value needed for Duplicate check
     $_REQUEST['Contactslast_name'] = $_POST['Contactslast_name'] = 'Test 40209';
     //require view and call display class so that convert functionality is called
     require_once 'modules/Leads/views/view.convertlead.php';
     $vc = new ViewConvertLead();
     $vc->display();
     //retrieve the lead again to make sure we have the latest converted lead in memory
     $this->lead->retrieve($this->lead->id);
     //retrieve the new contact id from the conversion
     $contact_id = $this->lead->contact_id;
     //throw error if contact id was not retrieved and exit test
     $this->assertNotEmpty($contact_id, "contact id was not created during conversion process.  An error has ocurred, aborting rest of test.");
     //make sure the new contact has the account related and that it matches the lead account
     $this->contact->retrieve($contact_id);
     $this->assertEquals($this->lead->account_id, $this->contact->account_id, "Account id from converted lead does not match the new contact account id, there was an error during conversion.");
 }