Example #1
0
 public function testBadQuery()
 {
     $lead = SugarTestLeadUtilities::createLead();
     $this->_login();
     $result = $this->_soapClient->call('get_entry_list', array('session' => $this->_sessionId, "module_name" => 'Leads', "query" => "leads.id = '{$lead->id}'", 'order_by' => '', 'offset' => 0, 'select_fields' => array('name'), 'link_name_to_fields_array' => array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address'))), 'max_results' => 1, 'deleted' => 0));
     $this->assertEquals('primary_address', $result['relationship_list'][0][0]['records'][0][3]['name']);
 }
 public function tearDown()
 {
     SugarTestHelper::tearDown();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }
Example #3
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'.");
 }
Example #4
0
 public function testBadQuery()
 {
     $lead = SugarTestLeadUtilities::createLead();
     $this->_login();
     $result = $this->_soapClient->call('get_entry_list', array('session' => $this->_sessionId, "module_name" => 'Leads', "query" => "leads.id = '{$lead->id}'", '', 0, array(), array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address')))));
     $this->assertEquals('primary_address', $result['relationship_list'][0][0]['records'][0][3]['name']);
 }
 /**
  * @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();
 }
 public function tearDown()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestLeadUtilities::removeAllCreatedLeads();
     SugarTestLeadUtilities::removeCreatedLeadsEmailAddresses();
     unset($this->form);
     unset($this->lead1);
 }
Example #7
0
 public function setUp()
 {
     //create user
     $this->user = $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     //create account
     $this->account = new Account();
     $this->account->name = 'bug40209 account ' . date('Y-m-d-H-i-s');
     $this->account->save();
     //create contact
     $this->contact = new Contact();
     $this->lead = SugarTestLeadUtilities::createLead();
 }
Example #8
0
 public function setUp()
 {
     global $_POST;
     $_POST = array();
     $reloadVardefs = isset($GLOBALS['reload_vardefs']) ? $GLOBALS['reload_vardefs'] : false;
     $GLOBALS['reload_vardefs'] = true;
     //create user
     $this->user = $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     //create account
     $this->account = new Account();
     $this->account->name = 'bug40209 account ' . date('Y-m-d-H-i-s');
     $this->account->save();
     //create contact
     $this->contact = new Contact();
     $this->lead = SugarTestLeadUtilities::createLead();
     $GLOBALS['reload_vardefs'] = $reloadVardefs;
 }
Example #9
0
 /**
  * setUp
  * Override the setup from SoapTestCase to also create the seed search data for Accounts and Contacts.
  */
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/soap.php';
     parent::setUp();
     $this->_login();
     // Logging in just before the SOAP call as this will also commit any pending DB changes
     $this->contact = SugarTestContactUtilities::createContact();
     $this->contact->contacts_users_id = $GLOBALS['current_user']->id;
     $this->contact->save();
     $this->account = SugarTestAccountUtilities::createAccount();
     $this->account->email1 = $this->contact->email1;
     $this->account->save();
     $this->lead = SugarTestLeadUtilities::createLead();
     $this->lead->email1 = $this->contact->email1;
     $this->lead->save();
     $GLOBALS['db']->commit();
     // Making sure these changes are committed to the database
 }
Example #10
0
 public function tearDown()
 {
     return;
     $GLOBALS['current_user'] = $this->saved_current_user;
     if ($this->remove_beans) {
         $this->campaign->mark_deleted($this->campaign->id);
         $this->prospectlist->mark_deleted($this->prospectlist->id);
         SugarTestContactUtilities::removeAllCreatedContacts();
         SugarTestLeadUtilities::removeAllCreatedLeads();
     }
     if ($this->clear_database) {
         $sql = 'DELETE FROM email_marketing WHERE campaign_id = \'' . $this->campaign->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM emailman WHERE campaign_id = \'' . $this->campaign->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM campaign_log WHERE campaign_id = \'' . $this->campaign->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM prospect_lists_prospects WHERE prospect_list_id=\'' . $this->prospectlist->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM prospect_lists_prospects WHERE prospect_list_id=\'' . $this->prospectlist2->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM prospect_lists WHERE id = \'' . $this->prospectlist->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM prospect_lists WHERE id = \'' . $this->prospectlist2->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM prospect_list_campaigns WHERE campaign_id = \'' . $this->campaign->id . '\'';
         $GLOBALS['db']->query($sql);
         $sql = 'DELETE FROM campaigns WHERE id = \'' . $this->campaign->id . '\'';
         $GLOBALS['db']->query($sql);
     }
 }
Example #11
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();
 }
Example #12
0
 public function testMissingFields()
 {
     $bean = $this->getMock('Call', array('get_importable_fields', 'populateDefaultValues', 'beforeImportSave', 'save', 'afterImportSave', 'writeRowToLastImport'));
     $bean->expects($this->any())->method('get_importable_fields')->will($this->returnValue(array('account_id' => 'accounts', 'opportunity_id' => 'opportunities', 'contact_id' => 'contacts', 'case_id' => 'cases', 'user_id' => 'users', 'assigned_user_id' => 'users', 'note_id' => 'notes', 'lead_id' => 'leads')));
     $bean->expects($this->any())->method('populateDefaultValues')->will($this->returnValue('foo'));
     $bean->expects($this->any())->method('beforeImportSave')->will($this->returnValue('foo'));
     $bean->expects($this->any())->method('save')->will($this->returnValue('foo'));
     $bean->expects($this->any())->method('afterImportSave')->will($this->returnValue('foo'));
     $bean->expects($this->any())->method('writeRowToLastImport')->will($this->returnValue('foo'));
     $bean->date_modified = 'true';
     $bean->fetched_row = array('date_modified' => '');
     $bean->object_name = '';
     $lead = SugarTestLeadUtilities::createLead();
     $a = new bug46411_Importer_mock($this->importSource, $bean);
     //        $b = new Call();
     $bean->parent_type = 'leads';
     $bean->parent_id = $lead->id;
     //        $bean->relationship_fields = $b->relationship_fields;
     $a->saveImportBean($bean, false);
     $this->assertEquals($bean->parent_id, $bean->lead_id);
 }
Example #13
0
 /**
  * @group bug44831
  */
 public function testJSInjection()
 {
     $this->markTestIncomplete('Marked as skipped for now... too problematic');
     return;
     require_once 'include/utils/layout_utils.php';
     $_SERVER['REQUEST_METHOD'] = "POST";
     $lead = SugarTestLeadUtilities::createLead();
     $lead->name = 'LeadName';
     $lead->save();
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'EditView';
     $_REQUEST['record'] = $lead->id;
     require_once 'include/MVC/Controller/ControllerFactory.php';
     require_once 'include/MVC/View/ViewFactory.php';
     $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
     //ob_start();
     $GLOBALS['app']->controller->execute();
     //$tStr = ob_get_clean();
     // First of all, need to be sure that I'm actually dealing with my new custom DetailView Layout
     $this->expectOutputRegex('/.*HiddenPlaceHolder.*/');
     // Then check inclusion of LeadJS1.js
     $this->expectOutputRegex('/.*<script src=\\"custom\\/modules\\/Leads\\/javascript\\/LeadJS1\\.js.*\\"><\\/script>.*/');
     // Then check inclusion of LeadJS2.js
     $this->expectOutputRegex('/.*<script src=\\"custom\\/modules\\/Leads\\/javascript\\/LeadJS2\\.js.*\\"><\\/script>.*/');
     //unset($GLOBALS['app']->controller);
     unset($_REQUEST['module']);
     unset($_REQUEST['action']);
     unset($_REQUEST['record']);
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }
Example #14
0
 /**
  * @group bug39787
  */
 public function testOpportunityNameValueFilled()
 {
     $lead = SugarTestLeadUtilities::createLead();
     $lead->opportunity_name = 'SBizzle Dollar Store';
     $lead->save();
     $_REQUEST['module'] = 'Leads';
     $_REQUEST['action'] = 'ConvertLead';
     $_REQUEST['record'] = $lead->id;
     // Check that the opportunity name doesn't get populated when it's not in the Leads editview layout
     require_once 'include/MVC/Controller/ControllerFactory.php';
     require_once 'include/MVC/View/ViewFactory.php';
     $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
     ob_start();
     $GLOBALS['app']->controller->execute();
     $output = ob_get_clean();
     $matches_one = array();
     $pattern = '/SBizzle Dollar Store/';
     preg_match($pattern, $output, $matches_one);
     $this->assertTrue(count($matches_one) == 0, "Opportunity name got carried over to the Convert Leads page when it shouldn't have.");
     // Add the opportunity_name to the Leads EditView
     SugarTestStudioUtilities::addFieldToLayout('Leads', 'editview', 'opportunity_name');
     // Check that the opportunity name now DOES get populated now that it's in the Leads editview layout
     ob_start();
     $GLOBALS['app']->controller = ControllerFactory::getController($_REQUEST['module']);
     $GLOBALS['app']->controller->execute();
     $output = ob_get_clean();
     $matches_two = array();
     $pattern = '/SBizzle Dollar Store/';
     preg_match($pattern, $output, $matches_two);
     $this->assertTrue(count($matches_two) > 0, "Opportunity name did not carry over to the Convert Leads page when it should have.");
     SugarTestStudioUtilities::removeAllCreatedFields();
     unset($GLOBALS['app']->controller);
     unset($_REQUEST['module']);
     unset($_REQUEST['action']);
     unset($_REQUEST['record']);
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }