3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 require_once 'include/database/DBManagerFactory.php';
41 class Bug43466 extends Sugar_PHPUnit_Framework_TestCase
47 public static function setUpBeforeClass()
49 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
53 public static function tearDownAfterClass()
55 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
56 unset($GLOBALS['current_user']);
59 public function setUp()
61 $this->_db = DBManagerFactory::getInstance();
62 $this->useOutputBuffering = false;
65 public function tearDown()
67 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
68 unset($GLOBALS['current_user']);
69 SugarTestContactUtilities::removeAllCreatedContacts();
76 public function providerRepairTableParams()
82 'vname' => 'LBL_SUBJECT',
83 'dbType' => 'varchar',
86 'comment' => 'Brief description of the call',
87 'unified_search' => true,
89 'importable' => 'required',
94 'name' => 'duration_hours',
95 'vname' => 'LBL_DURATION_HOURS',
98 'comment' => 'Call duration, hours portion',
101 'duration_minutes' =>
103 'name' => 'duration_minutes',
104 'vname' => 'LBL_DURATION_MINUTES',
106 'function' => array('name'=>'getDurationMinutesOptions', 'returns'=>'html', 'include'=>'modules/Calls/CallHelper.php'),
108 'group'=>'duration_hours',
109 'importable' => 'required',
110 'comment' => 'Call duration, minutes portion'
115 'name' => 'date_start',
116 'vname' => 'LBL_DATE',
117 'type' => 'datetimecombo',
118 'dbType' => 'datetime',
119 'comment' => 'Date in which call is schedule to (or did) start',
120 'importable' => 'required',
122 'enable_range_search' => true,
123 'options' => 'date_range_search_dom',
128 'name' => 'date_end',
129 'vname' => 'LBL_DATE_END',
130 'type' => 'datetimecombo',
132 'comment' => 'Date is which call is scheduled to (or did) end',
133 'enable_range_search' => true,
134 'options' => 'date_range_search_dom',
139 'name'=>'parent_type',
140 'vname'=>'LBL_PARENT_TYPE',
141 'type' => 'parent_type',
144 'group'=>'parent_name',
145 'options'=> 'parent_type_display',
147 'comment' => 'The Sugar object to which the call is related'
152 'name'=> 'parent_name',
153 'parent_type'=>'record_type_display' ,
154 'type_name'=>'parent_type',
155 'id_name'=>'parent_id',
156 'vname'=>'LBL_LIST_RELATED_TO',
158 'group'=>'parent_name',
160 'options'=> 'parent_type_display',
165 'vname' => 'LBL_STATUS',
168 'options' => 'call_status_dom',
169 'comment' => 'The status of the call (Held, Not Held, etc.)',
171 'importable' => 'required',
172 'default' => 'Planned',
176 'name' => 'direction',
177 'vname' => 'LBL_DIRECTION',
180 'options' => 'call_direction_dom',
181 'comment' => 'Indicates whether call is inbound or outbound'
186 'vname'=>'LBL_LIST_RELATED_TO_ID',
188 'group'=>'parent_name',
190 'comment' => 'The ID of the parent Sugar object identified by parent_type'
194 'name' => 'reminder_checked',
195 'vname' => 'LBL_REMINDER',
197 'source' => 'non-db',
198 'comment' => 'checkbox indicating whether or not the reminder value is set (Meta-data only)',
203 'name' => 'reminder_time',
204 'vname' => 'LBL_REMINDER_TIME',
207 'options' => 'reminder_time_options',
208 'reportable' => false,
209 'massupdate' => false,
211 'comment' => 'Specifies when a reminder alert should be issued; -1 means no alert; otherwise the number of seconds prior to the start'
213 'email_reminder_checked' => array(
214 'name' => 'email_reminder_checked',
215 'vname' => 'LBL_EMAIL_REMINDER',
217 'source' => 'non-db',
218 'comment' => 'checkbox indicating whether or not the email reminder value is set (Meta-data only)',
219 'massupdate' => false,
221 'email_reminder_time' =>
223 'name' => 'email_reminder_time',
224 'vname' => 'LBL_EMAIL_REMINDER_TIME',
227 'options' => 'reminder_time_options',
228 'reportable' => false,
229 'massupdate' => false,
231 'comment' => 'Specifies when a email reminder alert should be issued; -1 means no alert; otherwise the number of seconds prior to the start'
233 'email_reminder_sent' => array(
234 'name' => 'email_reminder_sent',
235 'vname' => 'LBL_EMAIL_REMINDER_SENT',
238 'comment' => 'Whether email reminder is already sent',
240 'massupdate'=> false,
245 'name' => 'outlook_id',
246 'vname' => 'LBL_OUTLOOK_ID',
249 'reportable' => false,
250 'comment' => 'When the Sugar Plug-in for Microsoft Outlook syncs an Outlook appointment, this is the Outlook appointment item ID'
254 'name' => 'accept_status',
255 'vname' => 'LBL_SUBJECT',
256 'dbType' => 'varchar',
262 'set_accept_links' =>
264 'name' => 'accept_status',
265 'vname' => 'LBL_SUBJECT',
266 'dbType' => 'varchar',
273 'name' => 'contact_name',
274 'rname' => 'last_name',
275 'db_concat_fields'=> array(0=>'first_name', 1=>'last_name'),
276 'id_name' => 'contact_id',
277 'massupdate' => false,
278 'vname' => 'LBL_CONTACT_NAME',
281 'table' => 'contacts',
283 'module' => 'Contacts',
284 'join_name' => 'contacts',
285 'dbType' => 'varchar',
288 'importable' => 'false',
289 'studio' => array('required' => false, 'listview'=>true, 'visible' => false),
295 'relationship' => 'account_calls',
298 'vname'=>'LBL_OLD_ACCOUNT_LINK',
302 'name' => 'opportunity',
304 'relationship' => 'opportunity_calls',
307 'vname'=>'LBL_OPPORTUNITY',
313 'relationship' => 'calls_leads',
315 'vname'=>'LBL_LEADS',
321 'relationship' => 'case_calls',
328 'name' => 'accounts',
330 'relationship' => 'account_calls',
331 'module'=>'Accounts',
332 'bean_name'=>'Account',
334 'vname'=>'LBL_ACCOUNT',
338 'name' => 'contacts',
340 'relationship' => 'calls_contacts',
342 'vname'=>'LBL_CONTACTS',
348 'relationship' => 'calls_users',
350 'vname'=>'LBL_USERS',
356 'relationship' => 'calls_notes',
360 'vname'=>'LBL_NOTES',
364 'name' => 'created_by_link',
366 'relationship' => 'calls_created_by',
367 'vname' => 'LBL_CREATED_BY_USER',
368 'link_type' => 'one',
373 'modified_user_link' =>
375 'name' => 'modified_user_link',
377 'relationship' => 'calls_modified_user',
378 'vname' => 'LBL_MODIFIED_BY_USER',
379 'link_type' => 'one',
384 'assigned_user_link' =>
386 'name' => 'assigned_user_link',
388 'relationship' => 'calls_assigned_user',
389 'vname' => 'LBL_ASSIGNED_TO_USER',
390 'link_type' => 'one',
397 'name' => 'contact_id',
399 'source' => 'non-db',
400 'importable' => false,
405 $returnArray = array (
411 'name' => 'idx_call_name',
413 'fields'=> array('name'),
416 'name' => 'idx_status',
418 'fields'=> array('status'),
421 'name' => 'idx_CALLS_date_Start',
423 'fields' => array('date_start'),
433 'name' => 'idx_call_name2',
435 'fields'=> array('name'),
438 'name' => 'idx_status',
440 'fields'=> array('status'),
443 'name' => 'idx_CALLS_date_Start',
445 'fields' => array('date_start'),
455 'name' => 'iDX_cAll_NAMe',
457 'fields'=> array('name'),
460 'name' => 'idx_STAtus',
462 'fields'=> array('status'),
465 'name' => 'idx_CALLS_date_Start',
467 'fields' => array('date_start'),
477 'name' => 'idx_call_name',
479 'fields'=> array('name'),
482 'name' => 'idx_status',
484 'fields'=> array('status'),
487 'name' => 'idx_calls_date_start2',
489 'fields' => array('date_start'),
499 static function isEmpty($result){
500 if(trim($result) == ""){
507 * @dataProvider providerRepairTableParams
511 public function testRepairTableParams(
519 if ( $expectedResult ) {
520 $this->assertTrue($this->isEmpty($this->_db->repairTableParams($tablename, $fielddefs, $indices, false)));
523 $this->assertFalse($this->isEmpty($this->_db->repairTableParams($tablename, $fielddefs, $indices, false)));
528 public function providerCompareVardefs()
530 $returnArray = array(
597 * @dataProvider providerCompareVarDefs
600 public function testCompareVarDefs($fieldDef1,$fieldDef2,$expectedResult)
602 if ( $expectedResult ) {
603 $this->assertTrue($this->_db->compareVarDefs($fieldDef1,$fieldDef2));
606 $this->assertFalse($this->_db->compareVarDefs($fieldDef1,$fieldDef2));