Ejemplo n.º 1
0
 public function tearDown()
 {
     SugarTestHelper::tearDown();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestLeadUtilities::removeAllCreatedLeads();
 }
Ejemplo n.º 2
0
 public function tearDown()
 {
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestHelper::tearDown();
 }
Ejemplo n.º 3
0
 /**
  * @ticket 44858
  */
 public function testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm()
 {
     //test to check that if value of a dropdown field is already set in REQUEST object (from any form such as mass update form instead of search form)
     //i.e. search is made on empty string, but REQUEST object gets value of that dropdown field from some other form on the same page
     //then on clicking serach button, value of that field should not be used as filter in where clause
     $this->markTestIncomplete('This test should actually check that the $whereArray is indeed populated');
     return;
     //array to simulate REQUEST object
     $requestArray['module'] = 'Accounts';
     $requestArray['action'] = 'index';
     $requestArray['searchFormTab'] = 'basic_search';
     $requestArray['account_type'] = 'Analyst';
     //value of a dropdown field set in REQUEST object
     $requestArray['query'] = 'true';
     $requestArray['button'] = 'Search';
     $requestArray['globalLinksOpen'] = 'true';
     $requestArray['current_user_only_basic'] = 0;
     $account = SugarTestAccountUtilities::createAccount();
     $searchForm = new SearchForm($account, 'Accounts');
     require 'modules/Accounts/vardefs.php';
     require 'modules/Accounts/metadata/SearchFields.php';
     require 'modules/Accounts/metadata/searchdefs.php';
     $searchForm->searchFields = $searchFields[$searchForm->module];
     $searchForm->searchdefs = $searchdefs[$searchForm->module];
     $searchForm->populateFromArray($requestArray, 'basic_search', false);
     $whereArray = $searchForm->generateSearchWhere(true, $account->module_dir);
     //echo var_export($whereArray, true);
     $this->assertEquals(0, count($whereArray));
 }
Ejemplo n.º 4
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'.");
 }
Ejemplo n.º 5
0
 /**
  * @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();
 }
Ejemplo n.º 6
0
 public function tearDown()
 {
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
     parent::tearDown();
     parent::_tearDownTestUser();
     SugarTestHelper::tearDown();
 }
Ejemplo n.º 7
0
 public static function tearDownAfterClass()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     unset($GLOBALS['current_user']);
     $GLOBALS['db']->commit();
 }
Ejemplo n.º 8
0
 public function tearDown()
 {
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestEmailUtilities::removeAllCreatedEmails();
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
 }
Ejemplo n.º 9
0
 public function tearDown()
 {
     $this->relateField->delete($this->df);
     $this->rc->repairAndClearAll(array("rebuildExtensions", "clearVardefs"), array("Contact"), false, false);
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestHelper::tearDown();
 }
Ejemplo n.º 10
0
 /**
  * Tears down the fixture, for example, close a network connection.
  * This method is called after a test is executed.
  */
 public function tearDown()
 {
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
     SugarTestContactUtilities::removeAllCreatedContacts();
     parent::tearDown();
     SugarTestHelper::tearDown();
 }
Ejemplo n.º 11
0
 public function tearDown()
 {
     SugarTestHelper::tearDown();
     SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
     SugarTestEmailUtilities::removeAllCreatedEmails();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     $GLOBALS['app'] = $this->application;
 }
Ejemplo n.º 12
0
 public function tearDown()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestTrackerUtility::removeAllTrackerEntries();
     unset($GLOBALS['current_user']);
     unset($GLOBALS['app_strings']);
 }
Ejemplo n.º 13
0
 /**
  * Remove anything that was used during this test
  *
  */
 public function tearDown()
 {
     parent::tearDown();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     global $soap_version_test_accountId, $soap_version_test_opportunityId, $soap_version_test_contactId;
     unset($soap_version_test_accountId);
     unset($soap_version_test_opportunityId);
     unset($soap_version_test_contactId);
 }
Ejemplo n.º 14
0
 /**
  * Create account function
  */
 public function createAccount($name, $deleted = 0)
 {
     $account = SugarTestAccountUtilities::createAccount();
     $account->name = $account->account_name = $name;
     $account->deleted = $deleted;
     $account->save();
     $GLOBALS['db']->commit();
     return $account;
 }
Ejemplo n.º 15
0
 public function tearDown()
 {
     if ($this->email_id) {
         $GLOBALS['db']->query("delete from emails where id='{$this->email_id}'");
     }
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
 }
Ejemplo n.º 16
0
 public function tearDown()
 {
     $GLOBALS["db"]->query("DELETE FROM inbound_email WHERE id = '{$this->ie->id}'");
     $GLOBALS["db"]->query("DELETE FROM cases WHERE name = '{$this->ie->casename}'");
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeCreatedContactsEmailAddresses();
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestHelper::tearDown();
 }
Ejemplo n.º 17
0
 /**
  * Remove anything that was used during this test
  *
  */
 public function tearDown()
 {
     $this->_tearDownTestUser();
     $this->_user = null;
     $this->_sessionId = '';
     unset($GLOBALS['beanList']);
     unset($GLOBALS['beanFiles']);
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestContactUtilities::removeAllCreatedContacts();
 }
 public function testGetNamePlusEmailAddressesForComposeMultipleIds()
 {
     $account1 = SugarTestAccountUtilities::createAccount();
     $account2 = SugarTestAccountUtilities::createAccount();
     $account3 = SugarTestAccountUtilities::createAccount();
     $email = new Email();
     $addressString = $email->getNamePlusEmailAddressesForCompose('Accounts', array($account1->id, $account2->id, $account3->id));
     $this->assertContains("{$account1->name} <{$account1->email1}>", $addressString);
     $this->assertContains("{$account2->name} <{$account2->email1}>", $addressString);
     $this->assertContains("{$account3->name} <{$account3->email1}>", $addressString);
     SugarTestAccountUtilities::removeAllCreatedAccounts();
 }
Ejemplo n.º 19
0
 public function tearDown()
 {
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     unset($this->account);
     unset($GLOBALS['tabStructure']);
     unset($this->subPanel, $this->group_label);
     unset($GLOBALS['dictionary']["accounts_cases_10000"]);
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
     unset($GLOBALS['beanFiles']);
     unset($GLOBALS['beanList']);
 }
 public function tearDown()
 {
     if (!empty($this->jobs)) {
         $jobs = implode("','", $this->jobs);
         $this->db->query("DELETE FROM job_queue WHERE id IN ('{$jobs}')");
     }
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     $ids = SugarTestAccountUtilities::getCreatedAccountIds();
     if (!empty($ids)) {
         SugarTestAccountUtilities::removeAllCreatedAccounts();
     }
 }
Ejemplo n.º 21
0
 public function tearDown()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
     if (!empty($this->email_id)) {
         $GLOBALS['db']->query("DELETE FROM emails WHERE id='{$this->email_id}'");
         $GLOBALS['db']->query("DELETE FROM emails_beans WHERE email_id='{$this->email_id}'");
         $GLOBALS['db']->query("DELETE FROM emails_text WHERE email_id='{$this->email_id}'");
         $GLOBALS['db']->query("DELETE FROM emails_email_addr_rel WHERE email_id='{$this->email_id}'");
     }
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     parent::tearDown();
 }
Ejemplo n.º 22
0
 public function tearDown()
 {
     $this->custField->delete($this->df);
     $_REQUEST['repair_silent'] = 1;
     $rc = new RepairAndClear();
     $rc->repairAndClearAll(array("clearAll", "rebuildExtensions"), array("Accounts"), false, false);
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestHelper::tearDown();
     $GLOBALS['reload_vardefs'] = true;
     $o = new Account();
     $GLOBALS['reload_vardefs'] = false;
 }
Ejemplo n.º 23
0
 public function testAuditForRelatedFields()
 {
     $test_account_name = 'test account name after';
     $account = SugarTestAccountUtilities::createAccount();
     $this->obj->field_defs['account_name']['audited'] = 1;
     $this->obj->name = 'test';
     $this->obj->account_id = $account->id;
     $this->obj->save();
     $this->obj->retrieve();
     $this->obj->account_name = $test_account_name;
     $changes = $this->obj->db->getAuditDataChanges($this->obj);
     $this->assertEquals($changes['account_name']['after'], $test_account_name);
     SugarTestAccountUtilities::removeAllCreatedAccounts();
 }
Ejemplo n.º 24
0
 public function tearDown()
 {
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
     if (file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php.bak')) {
         copy($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php.bak', $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php');
         unlink($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php.bak');
     }
     if (file_exists('custom/modules/unified_search_modules_display.php.bak')) {
         copy('custom/modules/unified_search_modules_display.php.bak', 'custom/modules/unified_search_modules_display.php');
         unlink('custom/modules/unified_search_modules_display.php.bak');
     }
     SugarTestTaskUtilities::removeAllCreatedTasks();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
 }
Ejemplo n.º 25
0
 /**
  * @ticket 49281
  */
 public function testInsertUpdateLongData()
 {
     $acc = new Account();
     $acc->name = "PHPUNIT test";
     $acc->assigned_user_id = $GLOBALS['current_user']->id;
     $acc->sic_code = 'mnbvcxzasdfghjklpoiuytrewqmnbvcxzasdfghjklpoiuytre';
     $acc->save();
     $id = $acc->id;
     SugarTestAccountUtilities::setCreatedAccount(array($id));
     $acc = new Account();
     $acc->retrieve($id);
     $this->assertEquals('mnbvcxzasd', $acc->sic_code);
     $acc->sic_code = 'f094f59daaed0983a6a2e5913ddcc5fb';
     $acc->save();
     $acc = new Account();
     $acc->retrieve($id);
     $this->assertEquals('f094f59daa', $acc->sic_code);
 }
Ejemplo n.º 26
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
 }
Ejemplo n.º 27
0
 public function testGetEntryWhenContactHasMultipleAccountRelationshipsWorks()
 {
     $contact = SugarTestContactUtilities::createContact();
     $account1 = SugarTestAccountUtilities::createAccount();
     $account2 = SugarTestAccountUtilities::createAccount();
     $contact->load_relationship('accounts');
     $contact->accounts->add($account1->id);
     $contact->accounts->add($account2->id);
     $this->_login();
     $parameters = array('session' => $this->_sessionId, 'module_name' => 'Contacts', 'query' => "contacts.id = '{$contact->id}'", 'order_by' => '', 'offset' => 0, 'select_fields' => array('id', 'account_id', 'account_name'), 'max_results' => 250, 'deleted' => 0);
     $result = $this->_soapClient->call('get_entry_list', $parameters);
     $account_names = array($account1->name, $account2->name);
     $account_ids = array($account1->id, $account2->id);
     /*
     $this->assertEquals($result['entry_list'][0]['name_value_list'][1]['value'],$account1->name);
     $this->assertEquals($result['entry_list'][0]['name_value_list'][2]['value'],$account1->id);
     $this->assertEquals($result['entry_list'][1]['name_value_list'][1]['value'],$account2->name);
     $this->assertEquals($result['entry_list'][1]['name_value_list'][2]['value'],$account2->id);
     */
     $this->assertTrue(in_array($result['entry_list'][0]['name_value_list'][1]['value'], $account_names));
     $this->assertTrue(in_array($result['entry_list'][1]['name_value_list'][1]['value'], $account_names));
     $this->assertTrue(in_array($result['entry_list'][0]['name_value_list'][2]['value'], $account_ids));
     $this->assertTrue(in_array($result['entry_list'][1]['name_value_list'][2]['value'], $account_ids));
 }
Ejemplo n.º 28
0
 public function tearDown()
 {
     $this->df->deleteField($this->field);
     $account_ids = SugarTestAccountUtilities::getCreatedAccountIds();
     $contact_ids = SugarTestContactUtilities::getCreatedContactIds();
     $GLOBALS['db']->query('DELETE FROM accounts_contacts WHERE contact_id IN (\'' . implode("', '", $contact_ids) . '\') OR  account_id IN (\'' . implode("', '", $account_ids) . '\')');
     SugarTestContactUtilities::removeAllCreatedContacts();
     SugarTestAccountUtilities::removeAllCreatedAccounts();
     SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
     unset($GLOBALS['current_user']);
     unset($GLOBALS['beanFiles']);
     unset($GLOBALS['beanList']);
 }
Ejemplo n.º 29
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();
 }
Ejemplo n.º 30
0
 public static function staticJobFunctionAccount($job, $data = null)
 {
     SugarTestAccountUtilities::createAccount($data);
     return $data != "failme";
 }