示例#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 copyActivityWrapper($activity, $bean)
 {
     parent::copyActivityAndRelateToBean($activity, $bean);
 }
示例#6
0
 public function copyActivityWrapper($activity, $bean, $parent = array())
 {
     parent::copyActivityAndRelateToBean($activity, $bean, $parent);
 }
示例#7
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.");
 }