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' => 'datetime',
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',
206 'function' => array('name'=>'getReminderTime', 'returns'=>'html', 'include'=>'modules/Calls/CallHelper.php', 'onListView'=>true),
208 'reportable' => false,
211 'comment' => 'Specifies when a reminder alert should be issued; -1 means no alert; otherwise the number of seconds prior to the start'
216 'name' => 'outlook_id',
217 'vname' => 'LBL_OUTLOOK_ID',
220 'reportable' => false,
221 'comment' => 'When the Sugar Plug-in for Microsoft Outlook syncs an Outlook appointment, this is the Outlook appointment item ID'
225 'name' => 'accept_status',
226 'vname' => 'LBL_SUBJECT',
227 'dbType' => 'varchar',
233 'set_accept_links' =>
235 'name' => 'accept_status',
236 'vname' => 'LBL_SUBJECT',
237 'dbType' => 'varchar',
244 'name' => 'contact_name',
245 'rname' => 'last_name',
246 'db_concat_fields'=> array(0=>'first_name', 1=>'last_name'),
247 'id_name' => 'contact_id',
248 'massupdate' => false,
249 'vname' => 'LBL_CONTACT_NAME',
252 'table' => 'contacts',
254 'module' => 'Contacts',
255 'join_name' => 'contacts',
256 'dbType' => 'varchar',
259 'importable' => 'false',
260 'studio' => array('required' => false, 'listview'=>true, 'visible' => false),
266 'relationship' => 'account_calls',
269 'vname'=>'LBL_OLD_ACCOUNT_LINK',
273 'name' => 'opportunity',
275 'relationship' => 'opportunity_calls',
278 'vname'=>'LBL_OPPORTUNITY',
284 'relationship' => 'calls_leads',
286 'vname'=>'LBL_LEADS',
292 'relationship' => 'case_calls',
299 'name' => 'accounts',
301 'relationship' => 'account_calls',
302 'module'=>'Accounts',
303 'bean_name'=>'Account',
305 'vname'=>'LBL_ACCOUNT',
309 'name' => 'contacts',
311 'relationship' => 'calls_contacts',
313 'vname'=>'LBL_CONTACTS',
319 'relationship' => 'calls_users',
321 'vname'=>'LBL_USERS',
327 'relationship' => 'calls_notes',
331 'vname'=>'LBL_NOTES',
335 'name' => 'created_by_link',
337 'relationship' => 'calls_created_by',
338 'vname' => 'LBL_CREATED_BY_USER',
339 'link_type' => 'one',
344 'modified_user_link' =>
346 'name' => 'modified_user_link',
348 'relationship' => 'calls_modified_user',
349 'vname' => 'LBL_MODIFIED_BY_USER',
350 'link_type' => 'one',
355 'assigned_user_link' =>
357 'name' => 'assigned_user_link',
359 'relationship' => 'calls_assigned_user',
360 'vname' => 'LBL_ASSIGNED_TO_USER',
361 'link_type' => 'one',
368 'name' => 'contact_id',
370 'source' => 'non-db',
371 'importable' => false,
376 $returnArray = array (
382 'name' => 'idx_call_name',
384 'fields'=> array('name'),
387 'name' => 'idx_status',
389 'fields'=> array('status'),
392 'name' => 'idx_CALLS_date_Start',
394 'fields' => array('date_start'),
404 'name' => 'idx_call_name2',
406 'fields'=> array('name'),
409 'name' => 'idx_status',
411 'fields'=> array('status'),
414 'name' => 'idx_CALLS_date_Start',
416 'fields' => array('date_start'),
426 'name' => 'iDX_cAll_NAMe',
428 'fields'=> array('name'),
431 'name' => 'idx_STAtus',
433 'fields'=> array('status'),
436 'name' => 'idx_CALLS_date_Start',
438 'fields' => array('date_start'),
448 'name' => 'idx_call_name',
450 'fields'=> array('name'),
453 'name' => 'idx_status',
455 'fields'=> array('status'),
458 'name' => 'idx_calls_date_start2',
460 'fields' => array('date_start'),
470 static function isEmpty($result){
471 if(trim($result) == ""){
478 * @dataProvider providerRepairTableParams
482 public function testRepairTableParams(
490 if ( $expectedResult ) {
491 $this->assertTrue($this->isEmpty($this->_db->repairTableParams($tablename, $fielddefs, $indices, false)));
494 $this->assertFalse($this->isEmpty($this->_db->repairTableParams($tablename, $fielddefs, $indices, false)));
499 public function providerCompareVardefs()
501 $returnArray = array(
568 * @dataProvider providerCompareVarDefs
571 public function testCompareVarDefs($fieldDef1,$fieldDef2,$expectedResult)
573 if($this->_db->dbType=="oci8" && $fieldDef1['len'] > $fieldDef2['len']) {
574 $this->markTestSkipped("Oracle does not allow shrinking columns");
576 if ( $expectedResult ) {
577 $this->assertTrue($this->_db->compareVarDefs($fieldDef1,$fieldDef2));
580 $this->assertFalse($this->_db->compareVarDefs($fieldDef1,$fieldDef2));