2 require_once('modules/Import/ImportFieldSanitize.php');
3 require_once("modules/Import/ImportFile.php");
4 require_once('tests/SugarTestLangPackCreator.php');
6 class ImportFieldSanitizeTest extends Sugar_PHPUnit_Framework_TestCase
8 public function setUp()
10 $this->_ifs = new ImportFieldSanitize();
11 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
12 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
13 $GLOBALS['timedate'] = new TimeDate();
15 require('include/modules.php');
16 $GLOBALS['beanList'] = $beanList;
19 public function tearDown()
21 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
22 unset($GLOBALS['current_user']);
23 unset($GLOBALS['app_list_strings']);
24 unset($GLOBALS['beanList']);
25 $GLOBALS['timedate'] = new TimeDate();
28 public function testValidBool()
30 $this->assertEquals($this->_ifs->bool(0,array()),0);
31 $this->assertEquals($this->_ifs->bool('no',array()),0);
32 $this->assertEquals($this->_ifs->bool('off',array()),0);
33 $this->assertEquals($this->_ifs->bool('n',array()),0);
34 $this->assertEquals($this->_ifs->bool('yes',array()),1);
35 $this->assertEquals($this->_ifs->bool('y',array()),1);
36 $this->assertEquals($this->_ifs->bool('on',array()),1);
37 $this->assertEquals($this->_ifs->bool(1,array()),1);
40 public function testValidBoolVarchar()
42 $vardefs = array('dbType' => 'varchar');
44 $this->assertEquals($this->_ifs->bool(0,$vardefs),'off');
45 $this->assertEquals($this->_ifs->bool('no',$vardefs),'off');
46 $this->assertEquals($this->_ifs->bool('off',$vardefs),'off');
47 $this->assertEquals($this->_ifs->bool('n',$vardefs),'off');
48 $this->assertEquals($this->_ifs->bool('yes',$vardefs),'on');
49 $this->assertEquals($this->_ifs->bool('y',$vardefs),'on');
50 $this->assertEquals($this->_ifs->bool('on',$vardefs),'on');
51 $this->assertEquals($this->_ifs->bool(1,$vardefs),'on');
54 public function testInvalidBool()
56 $this->assertFalse($this->_ifs->bool('OK',array()));
57 $this->assertFalse($this->_ifs->bool('yep',array()));
60 public function testValidCurrency()
62 $this->_ifs->dec_sep = '.';
63 $this->_ifs->currency_symbol = '$';
65 $this->assertEquals($this->_ifs->currency('$100',array()),100);
68 public function testInvalidCurrency()
70 $this->_ifs->dec_sep = '.';
71 $this->_ifs->currency_symbol = '�';
73 $this->assertNotEquals($this->_ifs->currency('$123.23',array()),123.23);
76 public function testValidDatetimeSameFormat()
78 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
80 $this->_ifs->dateformat = $GLOBALS['timedate']->get_date_format();
81 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
82 $this->_ifs->timezone = 'America/New_York';
83 $vardef = array('name' => 'some_date');
84 $date = date($this->_ifs->dateformat . ' ' .$this->_ifs->timeformat);
87 $GLOBALS['timedate']->get_db_date_time_format(),
89 $GLOBALS['timedate']->handle_offset(
90 $date, $GLOBALS['timedate']->get_date_time_format(), false,
91 $GLOBALS['current_user'], 'America/New_York')
96 $this->_ifs->datetime(
101 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
104 public function testValidDatetimeDifferentFormat()
106 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
108 $this->_ifs->dateformat = 'm/d/Y';
109 if ( $this->_ifs->dateformat == $GLOBALS['timedate']->get_date_format() )
110 $this->_ifs->dateformat = 'Y/m/d';
111 $this->_ifs->timeformat = 'h:ia';
112 if ( $this->_ifs->timeformat == $GLOBALS['timedate']->get_time_format() )
113 $this->_ifs->timeformat = 'h.ia';
114 $this->_ifs->timezone = 'America/New_York';
115 $vardef = array('name' => 'some_date');
116 $date = date($this->_ifs->dateformat . ' ' . $this->_ifs->timeformat);
119 $GLOBALS['timedate']->get_db_date_time_format(),
121 $GLOBALS['timedate']->handle_offset(
122 $date, $GLOBALS['timedate']->get_date_time_format(), false,
123 $GLOBALS['current_user'], 'America/New_York')
127 $this->_ifs->datetime(
132 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
135 public function testValidDatetimeDifferentTimezones()
137 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
139 $this->_ifs->dateformat = $GLOBALS['timedate']->get_date_format();
140 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
141 $format = $GLOBALS['timedate']->get_date_time_format();
142 $this->_ifs->timezone = 'America/Denver';
143 $vardef = array('name' => 'some_date');
144 $date = date($format);
146 $GLOBALS['timedate']->get_db_date_time_format(),
147 strtotime('+2 hours',strtotime(
148 $GLOBALS['timedate']->handle_offset(
149 $date, $GLOBALS['timedate']->get_date_time_format(), false,
150 $GLOBALS['current_user'], 'America/New_York')
154 $this->_ifs->datetime(
159 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
162 public function testValidDatetimeDateEntered()
164 $_SESSION[$GLOBALS['current_user']->id.'_PREFERENCES']['global']['timezone'] = 'Atlantic/Cape_Verde';
166 $this->_ifs->dateformat = $GLOBALS['timedate']->get_date_format();
167 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
168 $format = $GLOBALS['timedate']->get_date_time_format();
169 $this->_ifs->timezone = 'Atlantic/Cape_Verde';
170 $vardef = array('name' => 'date_entered');
171 $date = date($format);
173 $GLOBALS['timedate']->get_db_date_time_format(),
174 strtotime('+1 hours',strtotime($date)));
177 $this->_ifs->datetime(
182 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
185 public function testValidDatetimeDateOnly()
187 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
189 $this->_ifs->dateformat = $GLOBALS['timedate']->get_date_format();
190 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
191 $format = $GLOBALS['timedate']->get_date_format();
192 $this->_ifs->timezone = 'America/New_York';
193 $vardef = array('name' => 'date_entered');
194 $date = date($format);
196 $GLOBALS['timedate']->get_db_date_time_format(),
200 (bool) $this->_ifs->datetime(
204 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
207 public function testInvalidDatetime()
209 $this->_ifs->dateformat = 'm.d.Y';
210 $this->_ifs->timeformat = 'h:ia';
211 $this->_ifs->timezone = 'America/New_York';
214 $this->_ifs->datetime(
216 array('name' => 'some_date')));
219 public function testInvalidDatetimeBadDayBadHour()
221 $this->_ifs->dateformat = 'm.d.Y';
222 $this->_ifs->timeformat = 'h:ia';
223 $this->_ifs->timezone = 'America/New_York';
226 $this->_ifs->datetime(
228 array('name' => 'some_date')));
231 public function testValidDateSameFormat()
233 $this->_ifs->dateformat = $GLOBALS['timedate']->get_date_format();
234 $date = date($this->_ifs->dateformat);
243 public function testValidDateDifferentFormat()
245 $this->_ifs->dateformat = 'm/d/Y';
246 if ( $this->_ifs->dateformat == $GLOBALS['timedate']->get_date_format() )
247 $this->_ifs->dateformat = 'Y/m/d';
248 $date = date($this->_ifs->dateformat );
250 $GLOBALS['timedate']->get_date_format(),
260 public function testInvalidDate()
262 $this->_ifs->dateformat = 'm/d/Y';
270 public function testInvalidDateBadMonth()
272 $this->_ifs->dateformat = 'm/d/Y';
280 public function testValidEmail()
284 'sugas@sugarcrm.com',array()),
285 'sugas@sugarcrm.com');
288 public function testInvalidEmail()
292 'sug$%$@as@sugarcrm.com',array()));
295 public function testValidEnum()
297 $vardefs = array('options' => 'salutation_dom');
305 public function testInvalidEnum()
307 $vardefs = array('options' => 'salutation_dom');
317 public function testEnumWithDisplayValue()
319 $langpack = new SugarTestLangPackCreator();
320 $langpack->setAppListString('checkbox_dom',array(''=>'','1'=>'Yep','2'=>'Nada'));
323 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
325 $vardefs = array('options' => 'checkbox_dom');
336 public function testEnumWithExtraSpacesAtTheEnd()
338 $langpack = new SugarTestLangPackCreator();
339 $langpack->setAppListString('checkbox_dom',array(''=>'','1'=>'Yep','2'=>'Nada'));
342 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
344 $vardefs = array('options' => 'checkbox_dom');
355 public function testEnumWithKeyInDifferentCase()
357 $langpack = new SugarTestLangPackCreator();
358 $langpack->setAppListString('gender_list',array('male' => 'Male','female' => 'Female',));
361 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
363 $vardefs = array('options' => 'gender_list');
374 public function testEnumWithValueInDifferentCase()
376 $langpack = new SugarTestLangPackCreator();
377 $langpack->setAppListString('checkbox_dom',array(''=>'','1'=>'Yep','2'=>'Nada'));
380 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
382 $vardefs = array('options' => 'checkbox_dom');
390 public function testValidId()
394 '1234567890',array()),
398 public function testInvalidId()
402 '1234567890123456789012345678901234567890',array()));
405 public function testValidInt()
407 $this->assertEquals($this->_ifs->int('100',array()),100);
409 $this->_ifs->num_grp_sep = ',';
411 $this->assertEquals($this->_ifs->int('1,123',array()),1123);
414 public function testInvalidInt()
416 $this->_ifs->num_grp_sep = '.';
417 $this->assertFalse($this->_ifs->int('123,23',array()));
418 $this->_ifs->num_grp_sep = ',';
419 $this->assertFalse($this->_ifs->int('123.23',array()));
422 public function testValidFloat()
424 $this->_ifs->dec_sep = '.';
426 $this->assertEquals($this->_ifs->currency('100',array()),100);
427 $this->assertEquals($this->_ifs->currency('123.23',array()),123.23);
429 $this->_ifs->dec_sep = ',';
431 $this->assertEquals($this->_ifs->currency('123,23',array()),123.23);
433 $this->_ifs->num_grp_sep = ',';
435 $this->assertEquals($this->_ifs->currency('1,123.23',array()),1123.23);
438 public function testInvalidFloat()
440 $this->_ifs->dec_sep = '.';
442 $this->assertNotEquals($this->_ifs->currency('123,23',array()),123.23);
445 public function testValidFullname()
447 $this->_ifs->default_locale_name_format = 'l f';
449 $focus = loadBean('Contacts');
451 $this->_ifs->fullname('Bar Foo',array(),$focus);
453 $this->assertEquals($focus->first_name,'Foo');
454 $this->assertEquals($focus->last_name,'Bar');
457 public function testInvalidFullname()
459 $this->_ifs->default_locale_name_format = 'f l';
461 $focus = loadBean('Contacts');
463 $this->_ifs->fullname('Bar Foo',array(),$focus);
465 $this->assertNotEquals($focus->first_name,'Foo');
466 $this->assertNotEquals($focus->last_name,'Bar');
469 public function testValidMultiEnum()
471 $vardefs = array('options' => 'salutation_dom');
474 $this->_ifs->multienum(
475 'Mr.,Mrs.',$vardefs),
476 encodeMultienumValue(array('Mr.', 'Mrs.')));
478 $this->_ifs->multienum(
479 '^Mr.^,^Mrs.^',$vardefs),
480 encodeMultienumValue(array('Mr.', 'Mrs.')));
486 public function testValidMultiEnumWhenSpacesExistInTheValue()
488 $vardefs = array('options' => 'salutation_dom');
491 $this->_ifs->multienum(
492 'Mr., Mrs.',$vardefs),
493 encodeMultienumValue(array('Mr.', 'Mrs.')));
496 public function testInvalidMultiEnum()
498 $vardefs = array('options' => 'salutation_dom');
501 $this->_ifs->multienum(
502 'Mr.,foo.',$vardefs));
505 public function testValidName()
509 '1234567890',array('len' => 12)),
513 public function testInvalidName()
517 '1234567890123456789012345678901234567890',array('len' => 12)),
521 public function testParent()
523 $account_name = 'test case account'.date("YmdHis");
524 $focus = loadBean('Accounts');
525 $focus->name = $account_name;
527 $account_id = $focus->id;
529 $focus = loadBean('Contacts');
532 'source' => 'non-db',
533 'name' => 'parent_name',
534 'vname' => 'LBL_FLEX_RELATE',
539 'importable' => 'false',
540 'duplicate_merge' => 'disabled',
541 'duplicate_merge_dom_value' => '0',
545 'options' => 'parent_type_display',
546 'studio' => 'visible',
547 'type_name' => 'parent_type',
548 'id_name' => 'parent_id',
549 'parent_type' => 'record_type_display',
551 $focus->parent_name = '';
552 $focus->parent_id = '';
553 $focus->parent_type = 'Accounts';
560 $this->assertEquals($focus->parent_id,$account_id);
562 $GLOBALS['db']->query("DELETE FROM accounts where id = '$account_id'");
565 public function testRelate()
567 $account_name = 'test case account'.date("YmdHis");
568 $focus = loadBean('Accounts');
569 $focus->name = $account_name;
571 $account_id = $focus->id;
573 $focus = loadBean('Contacts');
575 'name' => 'account_name',
577 'id_name' => 'account_id',
578 'vname' => 'LBL_ACCOUNT_NAME',
579 'join_name'=>'accounts',
581 'link' => 'accounts',
582 'table' => 'accounts',
584 'module' => 'Accounts',
585 'dbType' => 'varchar',
587 'source' => 'non-db',
588 'unified_search' => true,
596 $this->assertEquals($focus->account_id,$account_id);
598 $GLOBALS['db']->query("DELETE FROM accounts where id = '$account_id'");
601 public function testRelateCreateRecord()
603 $account_name = 'test case account'.date("YmdHis");
605 $focus = loadBean('Contacts');
607 'name' => 'account_name',
609 'id_name' => 'account_id',
610 'vname' => 'LBL_ACCOUNT_NAME',
611 'join_name'=>'accounts',
613 'link' => 'accounts',
614 'table' => 'accounts',
616 'module' => 'Accounts',
617 'dbType' => 'varchar',
619 'source' => 'non-db',
620 'unified_search' => true,
625 require('include/modules.php');
626 $GLOBALS['beanList'] = $beanList;
634 unset($GLOBALS['beanList']);
636 $result = $GLOBALS['db']->query(
637 "SELECT id FROM accounts where name = '$account_name'");
638 $relaterow = $focus->db->fetchByAssoc($result);
640 $this->assertEquals($focus->account_id,$relaterow['id']);
642 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
648 public function testRelateCreateRecordNoTableInVardef()
650 $account_name = 'test case account'.date("YmdHis");
652 $focus = loadBean('Contacts');
654 'name' => 'account_name',
656 'id_name' => 'account_id',
657 'vname' => 'LBL_ACCOUNT_NAME',
658 'join_name'=>'accounts',
660 'link' => 'accounts',
662 'module' => 'Accounts',
663 'dbType' => 'varchar',
665 'source' => 'non-db',
666 'unified_search' => true,
671 require('include/modules.php');
672 $GLOBALS['beanList'] = $beanList;
680 unset($GLOBALS['beanList']);
682 $result = $GLOBALS['db']->query(
683 "SELECT id FROM accounts where name = '$account_name'");
684 $relaterow = $focus->db->fetchByAssoc($result);
686 $this->assertEquals($focus->account_id,$relaterow['id']);
688 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
694 public function testRelateCreateRecordIfNoRnameParameter()
696 $account_name = 'test case account'.date("YmdHis");
698 $focus = loadBean('Contacts');
700 'name' => 'account_name',
701 'id_name' => 'account_id',
702 'vname' => 'LBL_ACCOUNT_NAME',
703 'join_name'=>'accounts',
705 'link' => 'accounts',
706 'table' => 'accounts',
708 'module' => 'Accounts',
709 'dbType' => 'varchar',
711 'source' => 'non-db',
712 'unified_search' => true,
717 require('include/modules.php');
718 $GLOBALS['beanList'] = $beanList;
726 unset($GLOBALS['beanList']);
728 $result = $GLOBALS['db']->query(
729 "SELECT id FROM accounts where name = '$account_name'");
730 $relaterow = $focus->db->fetchByAssoc($result);
732 $this->assertEquals($focus->account_id,$relaterow['id']);
734 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
740 public function testRelateCreateRecordCheckACL()
742 $account_name = 'test case account '.date("YmdHis");
744 $focus = new Import_Bug26897_Mock;
746 'name' => 'account_name',
748 'id_name' => 'account_id',
749 'vname' => 'LBL_CATEGORY_NAME',
750 'join_name'=>'accounts',
752 'link' => 'accounts_link',
753 'table' => 'accounts',
755 'module' => 'Import_Bug26897_Mock',
756 'dbType' => 'varchar',
758 'source' => 'non-db',
763 require('include/modules.php');
764 $beanList['Import_Bug26897_Mock'] = 'Import_Bug26897_Mock';
765 $beanFiles['Import_Bug26897_Mock'] = 'modules/Accounts/Account.php';
766 $GLOBALS['beanList'] = $beanList;
767 $GLOBALS['beanFiles'] = $beanFiles;
775 unset($GLOBALS['beanList']);
776 unset($GLOBALS['beanFiles']);
778 $result = $GLOBALS['db']->query(
779 "SELECT id FROM accounts where name = '$account_name'");
780 $relaterow = $focus->db->fetchByAssoc($result);
782 $this->assertTrue(empty($focus->account_id),'Category ID should not be set');
783 $this->assertNull($relaterow,'Record should not be added to the related table');
785 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
791 public function testRelateDoNotCreateRecordIfRelatedModuleIsUsers()
793 $account_name = 'test case account'.date("YmdHis");
796 'name' => 'account_name',
798 'id_name' => 'category_id',
799 'vname' => 'LBL_CATEGORY_NAME',
800 'join_name'=>'accounts',
802 'link' => 'account_link',
806 'dbType' => 'varchar',
808 'source' => 'non-db',
817 unset($GLOBALS['beanList']);
818 unset($GLOBALS['beanFiles']);
820 $result = $GLOBALS['db']->query(
821 "SELECT id FROM accounts where name = '$account_name'");
822 $relaterow = $focus->db->fetchByAssoc($result);
824 $this->assertTrue(empty($focus->account_id),'Category ID should not be set');
825 $this->assertNull($relaterow,'Record should not be added to the related table');
827 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
833 public function testRelateToUserNameWhenFullNameIsGiven()
837 require('include/modules.php');
838 $GLOBALS['beanList'] = $beanList;
839 $GLOBALS['beanFiles'] = $beanFiles;
841 $accountFocus = new Account;
842 $userFocus = SugarTestUserUtilities::createAnonymousUser();
844 "name" => "assigned_user_name",
845 "link" => "assigned_user_link",
846 "vname" => "LBL_ASSIGNED_TO_NAME",
847 "rname" => "user_name",
849 "reportable" => false,
850 "source" => "non-db",
852 "id_name" => "assigned_user_id",
854 "duplicate_merge" => "disabled",
858 $userFocus->user_name,
860 $userFocus->first_name.' '.$userFocus->last_name,
867 unset($GLOBALS['beanList']);
868 unset($GLOBALS['beanFiles']);
874 public function testRelateCreateRecordUsingMultipleFieldToLinkRecords()
876 $contact_name = 'testcase contact'.date("YmdHis");
878 $focus = new Import_Bug27562_Mock;
881 'name' => 'contact_name',
883 'id_name' => 'contact_id',
884 'vname' => 'LBL_CATEGORY_NAME',
885 'join_name'=>'contacts',
887 'link' => 'contact_link',
888 'table' => 'contacts',
890 'module' => 'Import_Bug27562_Mock',
891 'dbType' => 'varchar',
893 'source' => 'non-db',
898 require('include/modules.php');
899 $beanList['Import_Bug27562_Mock'] = 'Import_Bug27562_Mock';
900 $beanFiles['Import_Bug27562_Mock'] = 'modules/Contacts/Contact.php';
901 $GLOBALS['beanList'] = $beanList;
902 $GLOBALS['beanFiles'] = $beanFiles;
910 unset($GLOBALS['beanList']);
911 unset($GLOBALS['beanFiles']);
913 $nameParts = explode(' ',$contact_name);
914 $result = $GLOBALS['db']->query(
915 "SELECT id FROM contacts where first_name = '{$nameParts[0]}' and last_name = '{$nameParts[1]}'");
916 $relaterow = $focus->db->fetchByAssoc($result);
918 $this->assertEquals($focus->contact_id,$relaterow['id']);
920 $GLOBALS['db']->query("DELETE FROM contacts where id = '{$relaterow['id']}'");
923 public function testRelateDontCreateRecord()
925 $account_name = 'test case account'.date("YmdHis");
927 $focus = loadBean('Contacts');
929 'name' => 'account_name',
931 'id_name' => 'account_id',
932 'vname' => 'LBL_ACCOUNT_NAME',
933 'join_name'=>'accounts',
935 'link' => 'accounts',
936 'table' => 'accounts',
938 'module' => 'Accounts',
939 'dbType' => 'varchar',
941 'source' => 'non-db',
942 'unified_search' => true,
947 require('include/modules.php');
948 $GLOBALS['beanList'] = $beanList;
956 'Should return false since record could not be found'
960 unset($GLOBALS['beanList']);
962 $result = $GLOBALS['db']->query(
963 "SELECT id FROM accounts where name = '$account_name'");
964 $relaterow = $focus->db->fetchByAssoc($result);
965 $this->assertNull($relaterow,'Record should not have been created');
967 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
973 public function testRelateWithInvalidDataFormatting()
975 $langpack = new SugarTestLangPackCreator();
976 $langpack->setAppListString('checkbox_dom',array(''=>'','1'=>'Yep','2'=>'Nada'));
979 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
981 $account_name = 'test case category'.date("YmdHis");
983 $focus = new Import_Bug27046_Mock;
985 'name' => 'account_name',
987 'id_name' => 'account_id',
988 'vname' => 'LBL_ACCOUNT_NAME',
989 'join_name'=>'accounts',
991 'link' => 'accounts_link',
992 'table' => 'accounts',
994 'module' => 'Import_Bug27046_Mock',
995 'dbType' => 'varchar',
997 'source' => 'non-db',
1002 $beanList = array();
1003 require('include/modules.php');
1004 $beanList['Import_Bug27046_Mock'] = 'Import_Bug27046_Mock';
1005 $beanFiles['Import_Bug27046_Mock'] = 'modules/Accounts/Account.php';
1006 $GLOBALS['beanList'] = $beanList;
1007 $GLOBALS['beanFiles'] = $beanFiles;
1010 $this->_ifs->relate(
1014 'Should return false since field format is invalid'
1018 unset($GLOBALS['beanList']);
1020 $result = $GLOBALS['db']->query(
1021 "SELECT id FROM accounts where name = '$account_name'");
1022 $relaterow = $focus->db->fetchByAssoc($result);
1023 $this->assertNull($relaterow,'Record should not have been created');
1025 $GLOBALS['db']->query("DELETE FROM accounts where id = '{$relaterow['id']}'");
1028 public function testValidSyncToOutlookUser()
1030 $value = $GLOBALS['current_user']->id . ',' . $GLOBALS['current_user']->user_name;
1031 $bad_names = array();
1034 (bool) $this->_ifs->synctooutlook(
1039 'Test $this->_ifs->synctooutlook() not returning false');
1041 $this->assertEquals($bad_names,array());
1043 public function testInvalidSyncToOutlook()
1045 $value = "jghu8h8yhuh8hhi889898898";
1046 $bad_names = array();
1049 $this->_ifs->synctooutlook(
1054 'Test $this->_ifs->synctooutlook() should return false');
1057 public function testValidTimeSameFormat()
1059 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
1061 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
1062 $this->_ifs->timezone = 'America/New_York';
1063 $vardef = array('name' => 'some_date');
1064 $date = date($this->_ifs->timeformat);
1066 $this->assertEquals(
1072 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
1075 public function testValidTimeDifferentFormat()
1077 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
1079 $this->_ifs->timeformat = 'h:ia';
1080 if ( $this->_ifs->timeformat == $GLOBALS['timedate']->get_time_format() )
1081 $this->_ifs->timeformat = 'h.ia';
1082 $this->_ifs->timezone = 'America/New_York';
1083 $vardef = array('name' => 'some_date');
1085 $date = date($this->_ifs->timeformat);
1086 $comparedate = date(
1087 $GLOBALS['timedate']->get_time_format(),
1090 $this->assertEquals(
1096 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
1099 public function testValidTimeDifferentTimezones()
1101 $_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone'] = 'America/New_York';
1103 $this->_ifs->timeformat = $GLOBALS['timedate']->get_time_format();
1104 $this->_ifs->timezone = 'America/Denver';
1105 $vardef = array('name' => 'some_date');
1106 $date = date($this->_ifs->timeformat);
1107 $comparedate = date(
1108 $GLOBALS['timedate']->get_time_format(),
1109 strtotime('+2 hours',strtotime($date)));
1111 $this->assertEquals(
1117 unset($_SESSION[$GLOBALS['current_user']->user_name.'_PREFERENCES']['global']['timezone']);
1120 public function testInvalidTime()
1122 $this->_ifs->timeformat = 'h:ia';
1123 $this->_ifs->timezone = 'America/New_York';
1128 array('name' => 'some_date')));
1131 public function testInvalidTimeBadSeconds()
1133 $this->_ifs->timeformat = 'h:ia';
1134 $this->_ifs->timezone = 'America/New_York';
1139 array('name' => 'some_date')));
1143 class Import_Bug26897_Mock extends Account
1145 function ACLAccess($view,$is_owner='not_set')
1150 function bean_implements($interface)
1156 class Import_Bug27562_Mock extends Contact
1158 function ACLAccess($view,$is_owner='not_set')
1164 class Import_Bug27046_Mock extends Account
1166 function ACLAccess($view,$is_owner='not_set')
1171 function bean_implements($interface)
1176 function getFieldDefintion($name)