Completed
Push — develop ( edae1e...431cf5 )
by Adam
20:48
created
modules/AOW_WorkFlow/aow_utils.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -656,7 +656,7 @@
 block discarded – undo
656 656
         }
657 657
     }
658 658
 
659
-   return $users[0];
659
+    return $users[0];
660 660
 }
661 661
 
662 662
 function setLastUser($user_id, $id) {
Please login to merge, or discard this patch.
Spacing   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     die('Not A Valid Entry Point');
43 43
 }
44 44
 
45
-function getModuleFields($module, $view='EditView', $value = '', $valid = array())
45
+function getModuleFields($module, $view = 'EditView', $value = '', $valid = array())
46 46
 {
47 47
     global $app_strings, $beanList, $current_user;
48 48
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                                 $blockedModuleFields[$mod->module_dir]
80 80
                             ) && !$current_user->isAdmin()
81 81
                         ) {
82
-                            $GLOBALS['log']->debug('hiding ' . $arr['name'] . ' field from ' . $current_user->name);
82
+                            $GLOBALS['log']->debug('hiding '.$arr['name'].' field from '.$current_user->name);
83 83
                             continue;
84 84
                         }
85 85
                     }
@@ -107,44 +107,44 @@  discard block
 block discarded – undo
107 107
         }
108 108
     }
109 109
     asort($fields);
110
-    if($view == 'JSON'){
110
+    if ($view == 'JSON') {
111 111
         return json_encode($fields);
112 112
     }
113
-    if($view == 'EditView'){
113
+    if ($view == 'EditView') {
114 114
         return get_select_options_with_id($fields, $value);
115 115
     } else {
116 116
         return $fields[$value];
117 117
     }
118 118
 }
119 119
 
120
-function getRelModuleFields($module, $rel_field, $view='EditView',$value = ''){
120
+function getRelModuleFields($module, $rel_field, $view = 'EditView', $value = '') {
121 121
     global $beanList;
122 122
 
123
-    if($module == $rel_field){
123
+    if ($module == $rel_field) {
124 124
         return getModuleFields($module, $view, $value);
125 125
     }
126 126
 
127 127
     $mod = new $beanList[$module]();
128 128
     $data = $mod->field_defs[$rel_field];
129 129
 
130
-    if(isset($data['module']) && $data['module'] != ''){
130
+    if (isset($data['module']) && $data['module'] != '') {
131 131
         return getModuleFields($data['module'], $view, $value);
132 132
     }
133 133
 
134 134
 }
135 135
 
136
-function getRelatedModule($module, $rel_field){
136
+function getRelatedModule($module, $rel_field) {
137 137
     global $beanList;
138 138
 
139
-    if($module == $rel_field){
139
+    if ($module == $rel_field) {
140 140
         return $module;
141 141
     }
142 142
 
143 143
     $mod = new $beanList[$module]();
144 144
 
145
-    if(isset($arr['module']) && $arr['module'] != '') {
145
+    if (isset($arr['module']) && $arr['module'] != '') {
146 146
         return $arr['module'];
147
-    } else if($mod->load_relationship($rel_field)){
147
+    } else if ($mod->load_relationship($rel_field)) {
148 148
         return $mod->$rel_field->getRelatedModuleName();
149 149
     }
150 150
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
 }
154 154
 
155
-function getModuleTreeData($module){
155
+function getModuleTreeData($module) {
156 156
     global $beanList, $app_list_strings;
157 157
 
158 158
     $sort_fields = array();
@@ -165,33 +165,33 @@  discard block
 block discarded – undo
165 165
     );
166 166
 
167 167
     if ($module != '') {
168
-        if(isset($beanList[$module]) && $beanList[$module]){
168
+        if (isset($beanList[$module]) && $beanList[$module]) {
169 169
             $mod = new $beanList[$module]();
170 170
 
171
-            foreach($mod->get_linked_fields() as $name => $arr){
172
-                if(isset($arr['module']) && $arr['module'] != '') {
171
+            foreach ($mod->get_linked_fields() as $name => $arr) {
172
+                if (isset($arr['module']) && $arr['module'] != '') {
173 173
                     $rel_module = $arr['module'];
174
-                } else if($mod->load_relationship($name)){
174
+                } else if ($mod->load_relationship($name)) {
175 175
                     $rel_module = $mod->$name->getRelatedModuleName();
176 176
                 }
177 177
 
178 178
                 $rel_module_label = isset($app_list_strings['moduleList'][$rel_module]) ? $app_list_strings['moduleList'][$rel_module] : $rel_module;
179
-                if(isset($arr['vname']) && $arr['vname'] != '') {
180
-                    $label = $rel_module_label . ' : ' . translate($arr['vname'], $mod->module_dir);
181
-                    $module_label = trim(translate($arr['vname'],$mod->module_dir),':');
182
-                }else {
183
-                    $label = $rel_module_label . ' : '. $name;
179
+                if (isset($arr['vname']) && $arr['vname'] != '') {
180
+                    $label = $rel_module_label.' : '.translate($arr['vname'], $mod->module_dir);
181
+                    $module_label = trim(translate($arr['vname'], $mod->module_dir), ':');
182
+                } else {
183
+                    $label = $rel_module_label.' : '.$name;
184 184
                     $module_label = $name;
185 185
                 }
186
-                $sort_fields[$name] = array('label'=>$label,'type'=>'relationship','module' => $rel_module,'module_label'=>$module_label);
187
-                if($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != ''){
188
-                    if(isset($fields[$arr['id_name']])){
189
-                        unset( $fields[$arr['id_name']]);
186
+                $sort_fields[$name] = array('label'=>$label, 'type'=>'relationship', 'module' => $rel_module, 'module_label'=>$module_label);
187
+                if ($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != '') {
188
+                    if (isset($fields[$arr['id_name']])) {
189
+                        unset($fields[$arr['id_name']]);
190 190
                     }
191 191
                 }
192 192
             } //End loop.
193
-            uasort($sort_fields,function($a,$b){
194
-                return strcmp($a['label'],$b['label']);
193
+            uasort($sort_fields, function($a, $b) {
194
+                return strcmp($a['label'], $b['label']);
195 195
             });
196 196
 
197 197
             $fields = array_merge((array)$fields, (array)$sort_fields);
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     return json_encode($fields);
202 202
 }
203 203
 
204
-function getModuleRelationships($module, $view='EditView',$value = '')
204
+function getModuleRelationships($module, $view = 'EditView', $value = '')
205 205
 {
206 206
     global $beanList, $app_list_strings;
207 207
 
@@ -210,27 +210,27 @@  discard block
 block discarded – undo
210 210
     $invalid_modules = array();
211 211
 
212 212
     if ($module != '') {
213
-        if(isset($beanList[$module]) && $beanList[$module]){
213
+        if (isset($beanList[$module]) && $beanList[$module]) {
214 214
             $mod = new $beanList[$module]();
215 215
 
216 216
             /*if($mod->is_AuditEnabled()){
217 217
                 $fields['Audit'] = translate('LBL_AUDIT_TABLE','AOR_Fields');
218 218
             }*/
219
-            foreach($mod->get_linked_fields() as $name => $arr){
220
-                if(isset($arr['module']) && $arr['module'] != '') {
219
+            foreach ($mod->get_linked_fields() as $name => $arr) {
220
+                if (isset($arr['module']) && $arr['module'] != '') {
221 221
                     $rel_module = $arr['module'];
222
-                } else if($mod->load_relationship($name)){
222
+                } else if ($mod->load_relationship($name)) {
223 223
                     $rel_module = $mod->$name->getRelatedModuleName();
224 224
                 }
225
-                if(!in_array($rel_module,$invalid_modules)){
225
+                if (!in_array($rel_module, $invalid_modules)) {
226 226
                     $relModuleName = isset($app_list_strings['moduleList'][$rel_module]) ? $app_list_strings['moduleList'][$rel_module] : $rel_module;
227
-                    if(isset($arr['vname']) && $arr['vname'] != ''){
228
-                        $sort_fields[$name] = $relModuleName.' : '.translate($arr['vname'],$mod->module_dir);
227
+                    if (isset($arr['vname']) && $arr['vname'] != '') {
228
+                        $sort_fields[$name] = $relModuleName.' : '.translate($arr['vname'], $mod->module_dir);
229 229
                     } else {
230
-                        $sort_fields[$name] = $relModuleName.' : '. $name;
230
+                        $sort_fields[$name] = $relModuleName.' : '.$name;
231 231
                     }
232
-                    if($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != ''){
233
-                        if(isset($fields[$arr['id_name']])) unset( $fields[$arr['id_name']]);
232
+                    if ($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != '') {
233
+                        if (isset($fields[$arr['id_name']])) unset($fields[$arr['id_name']]);
234 234
                     }
235 235
                 }
236 236
             } //End loop.
@@ -238,26 +238,26 @@  discard block
 block discarded – undo
238 238
             $fields = array_merge((array)$fields, (array)$sort_fields);
239 239
         }
240 240
     }
241
-    if($view == 'EditView'){
241
+    if ($view == 'EditView') {
242 242
         return get_select_options_with_id($fields, $value);
243 243
     } else {
244 244
         return $fields[$value];
245 245
     }
246 246
 }
247 247
 
248
-function getValidFieldsTypes($module, $field){
248
+function getValidFieldsTypes($module, $field) {
249 249
     global $beanFiles, $beanList;
250 250
 
251 251
     require_once($beanFiles[$beanList[$module]]);
252 252
     $focus = new $beanList[$module];
253 253
     $vardef = $focus->getFieldDefinition($field);
254 254
 
255
-    switch($vardef['type']) {
255
+    switch ($vardef['type']) {
256 256
         case 'double':
257 257
         case 'decimal':
258 258
         case 'float':
259 259
         case 'currency':
260
-            $valid_type = array('double','decimal','float','currency');
260
+            $valid_type = array('double', 'decimal', 'float', 'currency');
261 261
             break;
262 262
         case 'uint':
263 263
         case 'ulong':
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
         case 'short':
266 266
         case 'tinyint':
267 267
         case 'int':
268
-            $valid_type = array('uint','ulong','long','short','tinyint','int');
268
+            $valid_type = array('uint', 'ulong', 'long', 'short', 'tinyint', 'int');
269 269
             break;
270 270
         case 'date':
271 271
         case 'datetime':
272 272
         case 'datetimecombo':
273
-            $valid_type = array('date','datetime', 'datetimecombo');
273
+            $valid_type = array('date', 'datetime', 'datetimecombo');
274 274
             break;
275 275
         case 'id':
276 276
         case 'relate':
@@ -287,29 +287,29 @@  discard block
 block discarded – undo
287 287
 }
288 288
 
289 289
 
290
-function getModuleField($module, $fieldname, $aow_field, $view='EditView',$value = '', $alt_type = '', $currency_id = '', $params= array()){
290
+function getModuleField($module, $fieldname, $aow_field, $view = 'EditView', $value = '', $alt_type = '', $currency_id = '', $params = array()) {
291 291
     global $current_language, $app_strings, $app_list_strings, $current_user, $beanFiles, $beanList;
292 292
 
293 293
     // use the mod_strings for this module
294
-    $mod_strings = return_module_language($current_language,$module);
294
+    $mod_strings = return_module_language($current_language, $module);
295 295
 
296 296
     // set the filename for this control
297
-    $file = create_cache_directory('modules/AOW_WorkFlow/') . $module . $view . $alt_type . $fieldname . '.tpl';
297
+    $file = create_cache_directory('modules/AOW_WorkFlow/').$module.$view.$alt_type.$fieldname.'.tpl';
298 298
 
299 299
     $displayParams = array();
300 300
 
301
-    if ( !is_file($file)
301
+    if (!is_file($file)
302 302
         || inDeveloperMode()
303
-        || !empty($_SESSION['developerMode']) ) {
303
+        || !empty($_SESSION['developerMode'])) {
304 304
 
305
-        if ( !isset($vardef) ) {
305
+        if (!isset($vardef)) {
306 306
             require_once($beanFiles[$beanList[$module]]);
307 307
             $focus = new $beanList[$module];
308 308
             $vardef = $focus->getFieldDefinition($fieldname);
309 309
         }
310 310
 
311 311
         // Bug: check for AOR value SecurityGroups value missing
312
-        if(stristr($fieldname, 'securitygroups') != false && empty($vardef)) {
312
+        if (stristr($fieldname, 'securitygroups') != false && empty($vardef)) {
313 313
             require_once($beanFiles[$beanList['SecurityGroups']]);
314 314
             $module = 'SecurityGroups';
315 315
             $focus = new $beanList[$module];
@@ -320,36 +320,36 @@  discard block
 block discarded – undo
320 320
         //$displayParams['formName'] = 'EditView';
321 321
 
322 322
         // if this is the id relation field, then don't have a pop-up selector.
323
-        if( $vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) {
323
+        if ($vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) {
324 324
             $vardef['type'] = 'varchar';
325 325
         }
326 326
 
327
-        if(isset($vardef['precision'])) unset($vardef['precision']);
327
+        if (isset($vardef['precision'])) unset($vardef['precision']);
328 328
 
329 329
         //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
330 330
 
331 331
         //TODO Fix datetimecomebo
332 332
         //temp work around
333
-        if( $vardef['type'] == 'datetimecombo') {
333
+        if ($vardef['type'] == 'datetimecombo') {
334 334
             $vardef['type'] = 'datetime';
335 335
         }
336 336
 
337 337
         // trim down textbox display
338
-        if( $vardef['type'] == 'text' ) {
338
+        if ($vardef['type'] == 'text') {
339 339
             $vardef['rows'] = 2;
340 340
             $vardef['cols'] = 32;
341 341
         }
342 342
 
343 343
         // create the dropdowns for the parent type fields
344
-        if ( $vardef['type'] == 'parent_type' ) {
344
+        if ($vardef['type'] == 'parent_type') {
345 345
             $vardef['type'] = 'enum';
346 346
         }
347 347
 
348
-        if($vardef['type'] == 'link'){
348
+        if ($vardef['type'] == 'link') {
349 349
             $vardef['type'] = 'relate';
350 350
             $vardef['rname'] = 'name';
351 351
             $vardef['id_name'] = $vardef['name'].'_id';
352
-            if((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) {
352
+            if ((!isset($vardef['module']) || $vardef['module'] == '') && $focus->load_relationship($vardef['name'])) {
353 353
                 $relName = $vardef['name'];
354 354
                 $vardef['module'] = $focus->$relName->getRelatedModuleName();
355 355
             }
@@ -357,24 +357,24 @@  discard block
 block discarded – undo
357 357
         }
358 358
 
359 359
         //check for $alt_type
360
-        if ( $alt_type != '' ) {
360
+        if ($alt_type != '') {
361 361
             $vardef['type'] = $alt_type;
362 362
         }
363 363
 
364 364
         // remove the special text entry field function 'getEmailAddressWidget'
365
-        if ( isset($vardef['function'])
366
-            && ( $vardef['function'] == 'getEmailAddressWidget'
367
-                || $vardef['function']['name'] == 'getEmailAddressWidget' ) )
365
+        if (isset($vardef['function'])
366
+            && ($vardef['function'] == 'getEmailAddressWidget'
367
+                || $vardef['function']['name'] == 'getEmailAddressWidget'))
368 368
             unset($vardef['function']);
369 369
 
370
-        if(isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')){
370
+        if (isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')) {
371 371
             $vardef['name'] = 'aow_temp_date';
372 372
         }
373 373
 
374 374
         // load SugarFieldHandler to render the field tpl file
375 375
         static $sfh;
376 376
 
377
-        if(!isset($sfh)) {
377
+        if (!isset($sfh)) {
378 378
             require_once('include/SugarFields/SugarFieldHandler.php');
379 379
             $sfh = new SugarFieldHandler();
380 380
         }
@@ -384,17 +384,17 @@  discard block
 block discarded – undo
384 384
         // Remove all the copyright comments
385 385
         $contents = preg_replace('/\{\*[^\}]*?\*\}/', '', $contents);
386 386
 
387
-        if( $view == 'EditView' &&  ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')){
388
-            $contents = str_replace('"'.$vardef['id_name'].'"','{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents);
389
-            $contents = str_replace('"'.$vardef['name'].'"','{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents);
387
+        if ($view == 'EditView' && ($vardef['type'] == 'relate' || $vardef['type'] == 'parent')) {
388
+            $contents = str_replace('"'.$vardef['id_name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.id_name}"{literal}', $contents);
389
+            $contents = str_replace('"'.$vardef['name'].'"', '{/literal}"{$fields.'.$vardef['name'].'.name}"{literal}', $contents);
390 390
         }
391 391
 
392 392
         // hack to disable one of the js calls in this control
393
-        if ( isset($vardef['function']) && ( $vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown' ) )
393
+        if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown'))
394 394
             $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
395 395
 
396 396
         // Save it to the cache file
397
-        if($fh = @sugar_fopen($file, 'w')) {
397
+        if ($fh = @sugar_fopen($file, 'w')) {
398 398
             fputs($fh, $contents);
399 399
             fclose($fh);
400 400
         }
@@ -411,51 +411,51 @@  discard block
 block discarded – undo
411 411
     $ss->assign('TIME_FORMAT', $time_format);
412 412
     $time_separator = ":";
413 413
     $match = array();
414
-    if(preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) {
414
+    if (preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) {
415 415
         $time_separator = $match[1];
416 416
     }
417 417
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
418
-    if(!isset($match[2]) || $match[2] == '') {
419
-        $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M");
418
+    if (!isset($match[2]) || $match[2] == '') {
419
+        $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M");
420 420
     }
421 421
     else {
422 422
         $pm = $match[2] == "pm" ? "%P" : "%p";
423
-        $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm);
423
+        $ss->assign('CALENDAR_FORMAT', $date_format.' '.$t23.$time_separator."%M".$pm);
424 424
     }
425 425
 
426 426
     $ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
427 427
 
428 428
     // populate the fieldlist from the vardefs
429 429
     $fieldlist = array();
430
-    if ( !isset($focus) || !($focus instanceof SugarBean) )
430
+    if (!isset($focus) || !($focus instanceof SugarBean))
431 431
         require_once($beanFiles[$beanList[$module]]);
432 432
     $focus = new $beanList[$module];
433 433
     // create the dropdowns for the parent type fields
434 434
     $vardefFields = $focus->getFieldDefinitions();
435
-    if (isset($vardefFields[$fieldname]['type']) && $vardefFields[$fieldname]['type'] == 'parent_type' ) {
435
+    if (isset($vardefFields[$fieldname]['type']) && $vardefFields[$fieldname]['type'] == 'parent_type') {
436 436
         $focus->field_defs[$fieldname]['options'] = $focus->field_defs[$vardefFields[$fieldname]['group']]['options'];
437 437
     }
438
-    foreach ( $vardefFields as $name => $properties ) {
438
+    foreach ($vardefFields as $name => $properties) {
439 439
         $fieldlist[$name] = $properties;
440 440
         // fill in enums
441
-        if(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']]))
441
+        if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']]))
442 442
             $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
443 443
         // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings
444
-        elseif(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']]))
444
+        elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']]))
445 445
             $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
446 446
         // Bug 22730: make sure all enums have the ability to select blank as the default value.
447
-        if(!isset($fieldlist[$name]['options']['']))
447
+        if (!isset($fieldlist[$name]['options']['']))
448 448
             $fieldlist[$name]['options'][''] = '';
449 449
     }
450 450
 
451 451
     // fill in function return values
452
-    if ( !in_array($fieldname,array('email1','email2')) )
452
+    if (!in_array($fieldname, array('email1', 'email2')))
453 453
     {
454 454
         if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html')
455 455
         {
456 456
             $function = $fieldlist[$fieldname]['function']['name'];
457 457
             // include various functions required in the various vardefs
458
-            if ( isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include']))
458
+            if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include']))
459 459
                 require_once($fieldlist[$fieldname]['function']['include']);
460 460
             $_REQUEST[$fieldname] = $value;
461 461
             $value = $function($focus, $fieldname, $value, $view);
@@ -464,40 +464,40 @@  discard block
 block discarded – undo
464 464
         }
465 465
     }
466 466
 
467
-    if(isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link'){
467
+    if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link') {
468 468
         $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'].'_id';
469 469
 
470
-        if((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) {
470
+        if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) {
471 471
             $relName = $fieldlist[$fieldname]['name'];
472 472
             $fieldlist[$fieldname]['module'] = $focus->$relName->getRelatedModuleName();
473 473
         }
474 474
     }
475 475
 
476
-    if(isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')){
476
+    if (isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')) {
477 477
         $fieldlist[$fieldname]['name'] = 'aow_temp_date';
478 478
         $fieldlist['aow_temp_date'] = $fieldlist[$fieldname];
479 479
         $fieldname = 'aow_temp_date';
480 480
     }
481 481
 
482 482
     $quicksearch_js = '';
483
-    if(isset( $fieldlist[$fieldname]['id_name'] ) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']){
483
+    if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) {
484 484
         $rel_value = $value;
485 485
 
486 486
         require_once("include/TemplateHandler/TemplateHandler.php");
487 487
         $template_handler = new TemplateHandler();
488
-        $quicksearch_js = $template_handler->createQuickSearchCode($fieldlist,$fieldlist,$view);
488
+        $quicksearch_js = $template_handler->createQuickSearchCode($fieldlist, $fieldlist, $view);
489 489
         $quicksearch_js = str_replace($fieldname, $aow_field.'_display', $quicksearch_js);
490 490
         $quicksearch_js = str_replace($fieldlist[$fieldname]['id_name'], $aow_field, $quicksearch_js);
491 491
 
492 492
         echo $quicksearch_js;
493 493
 
494
-        if(isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users'){
494
+        if (isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users') {
495 495
             $rel_value = get_assigned_user_name($value);
496
-        } else if(isset($fieldlist[$fieldname]['module'])){
496
+        } else if (isset($fieldlist[$fieldname]['module'])) {
497 497
             require_once($beanFiles[$beanList[$fieldlist[$fieldname]['module']]]);
498 498
             $rel_focus = new $beanList[$fieldlist[$fieldname]['module']];
499 499
             $rel_focus->retrieve($value);
500
-            if(isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != ''){
500
+            if (isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != '') {
501 501
                 $relDisplayField = $fieldlist[$fieldname]['rname'];
502 502
             } else {
503 503
                 $relDisplayField = 'name';
@@ -510,17 +510,17 @@  discard block
 block discarded – undo
510 510
         $fieldlist[$fieldname]['id_name'] = $aow_field;
511 511
         $fieldlist[$fieldlist[$fieldname]['id_name']]['name'] = $aow_field;
512 512
         $fieldlist[$fieldname]['name'] = $aow_field.'_display';
513
-    } else if(isset( $fieldlist[$fieldname]['type'] ) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')){
513
+    } else if (isset($fieldlist[$fieldname]['type']) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) {
514 514
         $value = $focus->convertField($value, $fieldlist[$fieldname]);
515
-        if(!empty($params['date_format']) && isset($params['date_format'])){
515
+        if (!empty($params['date_format']) && isset($params['date_format'])) {
516 516
             $convert_format = "Y-m-d H:i:s";
517
-            if($fieldlist[$fieldname]['type'] == 'date') $convert_format = "Y-m-d";
517
+            if ($fieldlist[$fieldname]['type'] == 'date') $convert_format = "Y-m-d";
518 518
             $fieldlist[$fieldname]['value'] = $timedate->to_display($value, $convert_format, $params['date_format']);
519
-        }else{
519
+        } else {
520 520
             $fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true);
521 521
         }
522 522
         $fieldlist[$fieldname]['name'] = $aow_field;
523
-    } else if(isset( $fieldlist[$fieldname]['type'] ) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')){
523
+    } else if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) {
524 524
         $value = $focus->convertField($value, $fieldlist[$fieldname]);
525 525
         $fieldlist[$fieldname]['value'] = $timedate->to_display_date($value);
526 526
         //$fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true);
@@ -532,17 +532,17 @@  discard block
 block discarded – undo
532 532
 
533 533
     }
534 534
 
535
-    if(isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView'){
535
+    if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView') {
536 536
         static $sfh;
537 537
 
538
-        if(!isset($sfh)) {
538
+        if (!isset($sfh)) {
539 539
             require_once('include/SugarFields/SugarFieldHandler.php');
540 540
             $sfh = new SugarFieldHandler();
541 541
         }
542 542
 
543
-        if($currency_id != '' && !stripos($fieldname, '_USD')){
543
+        if ($currency_id != '' && !stripos($fieldname, '_USD')) {
544 544
             $userCurrencyId = $current_user->getPreference('currency');
545
-            if($currency_id != $userCurrencyId){
545
+            if ($currency_id != $userCurrencyId) {
546 546
                 $currency = new Currency();
547 547
                 $currency->retrieve($currency_id);
548 548
                 $value = $currency->convertToDollar($value);
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
     }
558 558
 
559 559
     $ss->assign("QS_JS", $quicksearch_js);
560
-    $ss->assign("fields",$fieldlist);
561
-    $ss->assign("form_name",$view);
562
-    $ss->assign("bean",$focus);
560
+    $ss->assign("fields", $fieldlist);
561
+    $ss->assign("form_name", $view);
562
+    $ss->assign("bean", $focus);
563 563
 
564 564
     // add in any additional strings
565 565
     $ss->assign("MOD", $mod_strings);
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
 
575
-function getDateField($module, $aow_field, $view, $value, $field_option = true){
575
+function getDateField($module, $aow_field, $view, $value, $field_option = true) {
576 576
     global $app_list_strings;
577 577
 
578 578
     // set $view = 'EditView' as default
@@ -582,21 +582,21 @@  discard block
 block discarded – undo
582 582
 
583 583
     $value = json_decode(html_entity_decode_utf8($value), true);
584 584
 
585
-    if(!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) unset($app_list_strings['aow_date_type_list']['business_hours']);
585
+    if (!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) unset($app_list_strings['aow_date_type_list']['business_hours']);
586 586
 
587 587
     $field = '';
588 588
 
589
-    if($view == 'EditView'){
590
-        $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' title='' tabindex='116'>". getDateFields($module, $view, $value[0], $field_option) ."</select>&nbsp;&nbsp;";
591
-        $field .= "<select type='text' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' onchange='date_field_change(\"$aow_field\")'  title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_operator'], $value[1]) ."</select>&nbsp;";
589
+    if ($view == 'EditView') {
590
+        $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' title='' tabindex='116'>".getDateFields($module, $view, $value[0], $field_option)."</select>&nbsp;&nbsp;";
591
+        $field .= "<select type='text' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' onchange='date_field_change(\"$aow_field\")'  title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_date_operator'], $value[1])."</select>&nbsp;";
592 592
         $display = 'none';
593
-        if($value[1] == 'plus' || $value[1] == 'minus') $display = '';
593
+        if ($value[1] == 'plus' || $value[1] == 'minus') $display = '';
594 594
         $field .= "<input  type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' value='$value[2]' tabindex='116'>&nbsp;";
595
-        $field .= "<select type='text' style='display:$display' name='$aow_field".'[3]'."' id='$aow_field".'[3]'."' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_type_list'], $value[3]) ."</select>";
595
+        $field .= "<select type='text' style='display:$display' name='$aow_field".'[3]'."' id='$aow_field".'[3]'."' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_date_type_list'], $value[3])."</select>";
596 596
     }
597 597
     else {
598 598
         $field = getDateFields($module, $view, $value[0], $field_option).' '.$app_list_strings['aow_date_operator'][$value[1]];
599
-        if($value[1] == 'plus' || $value[1] == 'minus'){
599
+        if ($value[1] == 'plus' || $value[1] == 'minus') {
600 600
             $field .= ' '.$value[2].' '.$app_list_strings['aow_date_type_list'][$value[3]];
601 601
         }
602 602
     }
@@ -604,21 +604,21 @@  discard block
 block discarded – undo
604 604
 
605 605
 }
606 606
 
607
-function getDateFields($module, $view='EditView',$value = '', $field_option = true)
607
+function getDateFields($module, $view = 'EditView', $value = '', $field_option = true)
608 608
 {
609 609
     global $beanList, $app_list_strings;
610 610
 
611 611
     $fields = $app_list_strings['aow_date_options'];
612 612
 
613
-    if(!$field_option) unset($fields['field']);
613
+    if (!$field_option) unset($fields['field']);
614 614
 
615 615
     if ($module != '') {
616
-        if(isset($beanList[$module]) && $beanList[$module]){
616
+        if (isset($beanList[$module]) && $beanList[$module]) {
617 617
             $mod = new $beanList[$module]();
618
-            foreach($mod->field_defs as $name => $arr){
619
-                if($arr['type'] == 'date' || $arr['type'] == 'datetime' || $arr['type'] == 'datetimecombo'){
620
-                    if(isset($arr['vname']) && $arr['vname'] != ''){
621
-                        $fields[$name] = translate($arr['vname'],$mod->module_dir);
618
+            foreach ($mod->field_defs as $name => $arr) {
619
+                if ($arr['type'] == 'date' || $arr['type'] == 'datetime' || $arr['type'] == 'datetimecombo') {
620
+                    if (isset($arr['vname']) && $arr['vname'] != '') {
621
+                        $fields[$name] = translate($arr['vname'], $mod->module_dir);
622 622
                     } else {
623 623
                         $fields[$name] = $name;
624 624
                     }
@@ -627,42 +627,42 @@  discard block
 block discarded – undo
627 627
 
628 628
         }
629 629
     }
630
-    if($view == 'EditView'){
630
+    if ($view == 'EditView') {
631 631
         return get_select_options_with_id($fields, $value);
632 632
     } else {
633 633
         return $fields[$value];
634 634
     }
635 635
 }
636 636
 
637
-function getAssignField($aow_field, $view, $value){
637
+function getAssignField($aow_field, $view, $value) {
638 638
     global $app_list_strings;
639 639
 
640 640
     $value = json_decode(html_entity_decode_utf8($value), true);
641 641
 
642
-    $roles = get_bean_select_array(true, 'ACLRole','name', '','name',true);
642
+    $roles = get_bean_select_array(true, 'ACLRole', 'name', '', 'name', true);
643 643
 
644
-    if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){
644
+    if (!file_exists('modules/SecurityGroups/SecurityGroup.php')) {
645 645
         unset($app_list_strings['aow_assign_options']['security_group']);
646 646
     }
647
-    else{
648
-        $securityGroups = get_bean_select_array(true, 'SecurityGroup','name', '','name',true);
647
+    else {
648
+        $securityGroups = get_bean_select_array(true, 'SecurityGroup', 'name', '', 'name', true);
649 649
     }
650 650
 
651 651
     $field = '';
652 652
 
653
-    if($view == 'EditView'){
654
-        $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' onchange='assign_field_change(\"$aow_field\")' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_assign_options'], $value[0]) ."</select>&nbsp;&nbsp;";
655
-        if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){
653
+    if ($view == 'EditView') {
654
+        $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' onchange='assign_field_change(\"$aow_field\")' title='' tabindex='116'>".get_select_options_with_id($app_list_strings['aow_assign_options'], $value[0])."</select>&nbsp;&nbsp;";
655
+        if (!file_exists('modules/SecurityGroups/SecurityGroup.php')) {
656 656
             $field .= "<input type='hidden' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' value=''  />";
657 657
         }
658 658
         else {
659 659
             $display = 'none';
660
-            if($value[0] == 'security_group') $display = '';
661
-            $field .= "<select type='text' style='display:$display' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' title='' tabindex='116'>". get_select_options_with_id($securityGroups, $value[1]) ."</select>&nbsp;&nbsp;";
660
+            if ($value[0] == 'security_group') $display = '';
661
+            $field .= "<select type='text' style='display:$display' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' title='' tabindex='116'>".get_select_options_with_id($securityGroups, $value[1])."</select>&nbsp;&nbsp;";
662 662
         }
663 663
         $display = 'none';
664
-        if($value[0] == 'role' || $value[0] == 'security_group') $display = '';
665
-        $field .= "<select type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' tabindex='116'>". get_select_options_with_id($roles, $value[2]) ."</select>&nbsp;&nbsp;";
664
+        if ($value[0] == 'role' || $value[0] == 'security_group') $display = '';
665
+        $field .= "<select type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' tabindex='116'>".get_select_options_with_id($roles, $value[2])."</select>&nbsp;&nbsp;";
666 666
     }
667 667
     else {
668 668
         $field = $app_list_strings['aow_assign_options'][$value[1]];
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 function getDropdownList($list_id, $selected_value) {
675 675
     global $app_list_strings;
676 676
     $option = '';
677
-    foreach($app_list_strings[$list_id] as $key => $value) {
678
-        if(base64_decode($selected_value) == $key) {
677
+    foreach ($app_list_strings[$list_id] as $key => $value) {
678
+        if (base64_decode($selected_value) == $key) {
679 679
             $option .= '<option value="'.$key.'" selected>'.$value.'</option>';
680
-        } else if($selected_value == $key) {
680
+        } else if ($selected_value == $key) {
681 681
             $option .= '<option value="'.$key.'" selected>'.$value.'</option>';
682 682
         }
683 683
         else {
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 }
689 689
 function getLeastBusyUser($users, $field, SugarBean $bean) {
690 690
     $counts = array();
691
-    foreach($users as $id) {
691
+    foreach ($users as $id) {
692 692
         $c = $bean->db->getOne("SELECT count(*) AS c FROM ".$bean->table_name." WHERE $field = '$id' AND deleted = 0");
693 693
         $counts[$id] = $c;
694 694
     }
@@ -699,21 +699,21 @@  discard block
 block discarded – undo
699 699
 
700 700
 function getRoundRobinUser($users, $id) {
701 701
 
702
-    $file = create_cache_directory('modules/AOW_WorkFlow/Users/') . $id . 'lastUser.cache.php';
702
+    $file = create_cache_directory('modules/AOW_WorkFlow/Users/').$id.'lastUser.cache.php';
703 703
 
704
-    if(isset($_SESSION['lastuser'][$id]) && $_SESSION['lastuser'][$id] != '') {
704
+    if (isset($_SESSION['lastuser'][$id]) && $_SESSION['lastuser'][$id] != '') {
705 705
         $users_by_key = array_flip($users); // now keys are values
706 706
         $key = $users_by_key[$_SESSION['lastuser'][$id]] + 1;
707
-        if(!empty($users[$key])) {
707
+        if (!empty($users[$key])) {
708 708
             return $users[$key];
709 709
         }
710 710
     }
711
-    else if (is_file($file)){
711
+    else if (is_file($file)) {
712 712
         require_once($file);
713
-        if(isset($lastUser['User']) && $lastUser['User'] != '') {
713
+        if (isset($lastUser['User']) && $lastUser['User'] != '') {
714 714
             $users_by_key = array_flip($users); // now keys are values
715 715
             $key = $users_by_key[$lastUser['User']] + 1;
716
-            if(!empty($users[$key])) {
716
+            if (!empty($users[$key])) {
717 717
                 return $users[$key];
718 718
             }
719 719
         }
@@ -726,31 +726,31 @@  discard block
 block discarded – undo
726 726
 
727 727
     $_SESSION['lastuser'][$id] = $user_id;
728 728
 
729
-    $file = create_cache_directory('modules/AOW_WorkFlow/Users/') . $id . 'lastUser.cache.php';
729
+    $file = create_cache_directory('modules/AOW_WorkFlow/Users/').$id.'lastUser.cache.php';
730 730
 
731 731
     $arrayString = var_export_helper(array('User' => $user_id));
732 732
 
733
-    $content =<<<eoq
733
+    $content = <<<eoq
734 734
 <?php
735 735
 	\$lastUser = {$arrayString};
736 736
 ?>
737 737
 eoq;
738 738
 
739
-    if($fh = @sugar_fopen($file, 'w')) {
739
+    if ($fh = @sugar_fopen($file, 'w')) {
740 740
         fputs($fh, $content);
741 741
         fclose($fh);
742 742
     }
743 743
     return true;
744 744
 }
745 745
 
746
-function getEmailableModules(){
746
+function getEmailableModules() {
747 747
     global $beanFiles, $beanList, $app_list_strings;
748 748
     $emailableModules = array();
749
-    foreach($app_list_strings['aow_moduleList'] as $bean_name => $bean_dis) {
750
-        if(isset($beanList[$bean_name]) && isset($beanFiles[$beanList[$bean_name]])){
749
+    foreach ($app_list_strings['aow_moduleList'] as $bean_name => $bean_dis) {
750
+        if (isset($beanList[$bean_name]) && isset($beanFiles[$beanList[$bean_name]])) {
751 751
             require_once($beanFiles[$beanList[$bean_name]]);
752 752
             $obj = new $beanList[$bean_name];
753
-            if($obj instanceof Person || $obj instanceof Company){
753
+            if ($obj instanceof Person || $obj instanceof Company) {
754 754
                 $emailableModules[] = $bean_name;
755 755
             }
756 756
         }
@@ -759,37 +759,37 @@  discard block
 block discarded – undo
759 759
     return $emailableModules;
760 760
 }
761 761
 
762
-function getRelatedEmailableFields($module){
762
+function getRelatedEmailableFields($module) {
763 763
     global $beanList, $app_list_strings;
764 764
     $relEmailFields = array();
765 765
     $checked_link = array();
766 766
     $emailableModules = getEmailableModules();
767 767
     if ($module != '') {
768
-        if(isset($beanList[$module]) && $beanList[$module]){
768
+        if (isset($beanList[$module]) && $beanList[$module]) {
769 769
             $mod = new $beanList[$module]();
770 770
 
771
-            foreach($mod->get_related_fields() as $field){
772
-                if(isset($field['link'])) $checked_link[] = $field['link'];
773
-                if(!isset($field['module']) || !in_array($field['module'],$emailableModules) || (isset($field['dbType']) && $field['dbType'] == "id")){
771
+            foreach ($mod->get_related_fields() as $field) {
772
+                if (isset($field['link'])) $checked_link[] = $field['link'];
773
+                if (!isset($field['module']) || !in_array($field['module'], $emailableModules) || (isset($field['dbType']) && $field['dbType'] == "id")) {
774 774
                     continue;
775 775
                 }
776
-                $relEmailFields[$field['name']] = $field['module'].": ".trim(translate($field['vname'],$mod->module_name),":");
776
+                $relEmailFields[$field['name']] = $field['module'].": ".trim(translate($field['vname'], $mod->module_name), ":");
777 777
             }
778 778
 
779
-            foreach($mod->get_linked_fields() as $field){
780
-                if(!in_array($field['name'],$checked_link) && !in_array($field['relationship'],$checked_link)){
781
-                    if(isset($field['module']) && $field['module'] != '') {
779
+            foreach ($mod->get_linked_fields() as $field) {
780
+                if (!in_array($field['name'], $checked_link) && !in_array($field['relationship'], $checked_link)) {
781
+                    if (isset($field['module']) && $field['module'] != '') {
782 782
                         $rel_module = $field['module'];
783
-                    } else if($mod->load_relationship($field['name'])){
783
+                    } else if ($mod->load_relationship($field['name'])) {
784 784
                         $relField = $field['name'];
785 785
                         $rel_module = $mod->$relField->getRelatedModuleName();
786 786
                     }
787 787
 
788
-                    if(in_array($rel_module,$emailableModules)) {
788
+                    if (in_array($rel_module, $emailableModules)) {
789 789
                         if (isset($field['vname']) && $field['vname'] != '') {
790
-                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . translate($field['vname'], $mod->module_dir);
790
+                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module].' : '.translate($field['vname'], $mod->module_dir);
791 791
                         } else {
792
-                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module] . ' : ' . $field['name'];
792
+                            $relEmailFields[$field['name']] = $app_list_strings['moduleList'][$rel_module].' : '.$field['name'];
793 793
                         }
794 794
                     }
795 795
                 }
@@ -810,37 +810,37 @@  discard block
 block discarded – undo
810 810
     
811 811
     static $boolean_false_values = array('off', 'false', '0', 'no');
812 812
 
813
-    switch($bean->field_defs[$field]['type']) {
813
+    switch ($bean->field_defs[$field]['type']) {
814 814
         case 'datetime':
815 815
         case 'datetimecombo':
816
-            if(empty($value)) break;
816
+            if (empty($value)) break;
817 817
             if ($value == 'NULL') {
818 818
                 $value = '';
819 819
                 break;
820 820
             }
821
-            if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/',$value) ) {
821
+            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $value)) {
822 822
                 // This appears to be formatted in user date/time
823 823
                 $value = $timedate->to_db($value);
824 824
             }
825 825
             break;
826 826
         case 'date':
827
-            if(empty($value)) break;
827
+            if (empty($value)) break;
828 828
             if ($value == 'NULL') {
829 829
                 $value = '';
830 830
                 break;
831 831
             }
832
-            if ( ! preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/',$value) ) {
832
+            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value)) {
833 833
                 // This date appears to be formatted in the user's format
834 834
                 $value = $timedate->to_db_date($value, false);
835 835
             }
836 836
             break;
837 837
         case 'time':
838
-            if(empty($value)) break;
838
+            if (empty($value)) break;
839 839
             if ($value == 'NULL') {
840 840
                 $value = '';
841 841
                 break;
842 842
             }
843
-            if ( preg_match('/(am|pm)/i',$value) ) {
843
+            if (preg_match('/(am|pm)/i', $value)) {
844 844
                 // This time appears to be formatted in the user's format
845 845
                 $value = $timedate->fromUserTime($value)->format(TimeDate::DB_TIME_FORMAT);
846 846
             }
@@ -849,10 +849,10 @@  discard block
 block discarded – undo
849 849
         case 'decimal':
850 850
         case 'currency':
851 851
         case 'float':
852
-            if ( $value === '' || $value == NULL || $value == 'NULL') {
852
+            if ($value === '' || $value == NULL || $value == 'NULL') {
853 853
                 continue;
854 854
             }
855
-            if ( is_string($value) ) {
855
+            if (is_string($value)) {
856 856
                 $value = (float)unformat_number($value);
857 857
             }
858 858
             break;
@@ -862,19 +862,19 @@  discard block
 block discarded – undo
862 862
         case 'short':
863 863
         case 'tinyint':
864 864
         case 'int':
865
-            if ( $value === '' || $value == NULL || $value == 'NULL') {
865
+            if ($value === '' || $value == NULL || $value == 'NULL') {
866 866
                 continue;
867 867
             }
868
-            if ( is_string($value) ) {
868
+            if (is_string($value)) {
869 869
                 $value = (int)unformat_number($value);
870 870
             }
871 871
             break;
872 872
         case 'bool':
873 873
             if (empty($value)) {
874 874
                 $value = false;
875
-            } else if(true === $value || 1 == $value) {
875
+            } else if (true === $value || 1 == $value) {
876 876
                 $value = true;
877
-            } else if(in_array(strval($value), $boolean_false_values)) {
877
+            } else if (in_array(strval($value), $boolean_false_values)) {
878 878
                 $value = false;
879 879
             } else {
880 880
                 $value = true;
Please login to merge, or discard this patch.
Braces   +66 added lines, -42 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                 if(isset($arr['vname']) && $arr['vname'] != '') {
180 180
                     $label = $rel_module_label . ' : ' . translate($arr['vname'], $mod->module_dir);
181 181
                     $module_label = trim(translate($arr['vname'],$mod->module_dir),':');
182
-                }else {
182
+                } else {
183 183
                     $label = $rel_module_label . ' : '. $name;
184 184
                     $module_label = $name;
185 185
                 }
@@ -230,7 +230,9 @@  discard block
 block discarded – undo
230 230
                         $sort_fields[$name] = $relModuleName.' : '. $name;
231 231
                     }
232 232
                     if($arr['type'] == 'relate' && isset($arr['id_name']) && $arr['id_name'] != ''){
233
-                        if(isset($fields[$arr['id_name']])) unset( $fields[$arr['id_name']]);
233
+                        if(isset($fields[$arr['id_name']])) {
234
+                            unset( $fields[$arr['id_name']]);
235
+                        }
234 236
                     }
235 237
                 }
236 238
             } //End loop.
@@ -324,7 +326,9 @@  discard block
 block discarded – undo
324 326
             $vardef['type'] = 'varchar';
325 327
         }
326 328
 
327
-        if(isset($vardef['precision'])) unset($vardef['precision']);
329
+        if(isset($vardef['precision'])) {
330
+            unset($vardef['precision']);
331
+        }
328 332
 
329 333
         //$vardef['precision'] = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
330 334
 
@@ -364,8 +368,9 @@  discard block
 block discarded – undo
364 368
         // remove the special text entry field function 'getEmailAddressWidget'
365 369
         if ( isset($vardef['function'])
366 370
             && ( $vardef['function'] == 'getEmailAddressWidget'
367
-                || $vardef['function']['name'] == 'getEmailAddressWidget' ) )
368
-            unset($vardef['function']);
371
+                || $vardef['function']['name'] == 'getEmailAddressWidget' ) ) {
372
+                    unset($vardef['function']);
373
+        }
369 374
 
370 375
         if(isset($vardef['name']) && ($vardef['name'] == 'date_entered' || $vardef['name'] == 'date_modified')){
371 376
             $vardef['name'] = 'aow_temp_date';
@@ -390,8 +395,9 @@  discard block
 block discarded – undo
390 395
         }
391 396
 
392 397
         // hack to disable one of the js calls in this control
393
-        if ( isset($vardef['function']) && ( $vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown' ) )
394
-            $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
398
+        if ( isset($vardef['function']) && ( $vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown' ) ) {
399
+                    $contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
400
+        }
395 401
 
396 402
         // Save it to the cache file
397 403
         if($fh = @sugar_fopen($file, 'w')) {
@@ -417,8 +423,7 @@  discard block
 block discarded – undo
417 423
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
418 424
     if(!isset($match[2]) || $match[2] == '') {
419 425
         $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M");
420
-    }
421
-    else {
426
+    } else {
422 427
         $pm = $match[2] == "pm" ? "%P" : "%p";
423 428
         $ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . "%M" . $pm);
424 429
     }
@@ -427,8 +432,9 @@  discard block
 block discarded – undo
427 432
 
428 433
     // populate the fieldlist from the vardefs
429 434
     $fieldlist = array();
430
-    if ( !isset($focus) || !($focus instanceof SugarBean) )
431
-        require_once($beanFiles[$beanList[$module]]);
435
+    if ( !isset($focus) || !($focus instanceof SugarBean) ) {
436
+            require_once($beanFiles[$beanList[$module]]);
437
+    }
432 438
     $focus = new $beanList[$module];
433 439
     // create the dropdowns for the parent type fields
434 440
     $vardefFields = $focus->getFieldDefinitions();
@@ -438,14 +444,17 @@  discard block
 block discarded – undo
438 444
     foreach ( $vardefFields as $name => $properties ) {
439 445
         $fieldlist[$name] = $properties;
440 446
         // fill in enums
441
-        if(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']]))
442
-            $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
447
+        if(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) {
448
+                    $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
449
+        }
443 450
         // Bug 32626: fall back on checking the mod_strings if not in the app_list_strings
444
-        elseif(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']]))
445
-            $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
451
+        elseif(isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) {
452
+                    $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
453
+        }
446 454
         // Bug 22730: make sure all enums have the ability to select blank as the default value.
447
-        if(!isset($fieldlist[$name]['options']['']))
448
-            $fieldlist[$name]['options'][''] = '';
455
+        if(!isset($fieldlist[$name]['options'][''])) {
456
+                    $fieldlist[$name]['options'][''] = '';
457
+        }
449 458
     }
450 459
 
451 460
     // fill in function return values
@@ -455,8 +464,9 @@  discard block
 block discarded – undo
455 464
         {
456 465
             $function = $fieldlist[$fieldname]['function']['name'];
457 466
             // include various functions required in the various vardefs
458
-            if ( isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include']))
459
-                require_once($fieldlist[$fieldname]['function']['include']);
467
+            if ( isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) {
468
+                            require_once($fieldlist[$fieldname]['function']['include']);
469
+            }
460 470
             $_REQUEST[$fieldname] = $value;
461 471
             $value = $function($focus, $fieldname, $value, $view);
462 472
 
@@ -514,9 +524,11 @@  discard block
 block discarded – undo
514 524
         $value = $focus->convertField($value, $fieldlist[$fieldname]);
515 525
         if(!empty($params['date_format']) && isset($params['date_format'])){
516 526
             $convert_format = "Y-m-d H:i:s";
517
-            if($fieldlist[$fieldname]['type'] == 'date') $convert_format = "Y-m-d";
527
+            if($fieldlist[$fieldname]['type'] == 'date') {
528
+                $convert_format = "Y-m-d";
529
+            }
518 530
             $fieldlist[$fieldname]['value'] = $timedate->to_display($value, $convert_format, $params['date_format']);
519
-        }else{
531
+        } else{
520 532
             $fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true);
521 533
         }
522 534
         $fieldlist[$fieldname]['name'] = $aow_field;
@@ -582,7 +594,9 @@  discard block
 block discarded – undo
582 594
 
583 595
     $value = json_decode(html_entity_decode_utf8($value), true);
584 596
 
585
-    if(!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) unset($app_list_strings['aow_date_type_list']['business_hours']);
597
+    if(!file_exists('modules/AOBH_BusinessHours/AOBH_BusinessHours.php')) {
598
+        unset($app_list_strings['aow_date_type_list']['business_hours']);
599
+    }
586 600
 
587 601
     $field = '';
588 602
 
@@ -590,11 +604,12 @@  discard block
 block discarded – undo
590 604
         $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' title='' tabindex='116'>". getDateFields($module, $view, $value[0], $field_option) ."</select>&nbsp;&nbsp;";
591 605
         $field .= "<select type='text' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' onchange='date_field_change(\"$aow_field\")'  title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_operator'], $value[1]) ."</select>&nbsp;";
592 606
         $display = 'none';
593
-        if($value[1] == 'plus' || $value[1] == 'minus') $display = '';
607
+        if($value[1] == 'plus' || $value[1] == 'minus') {
608
+            $display = '';
609
+        }
594 610
         $field .= "<input  type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' value='$value[2]' tabindex='116'>&nbsp;";
595 611
         $field .= "<select type='text' style='display:$display' name='$aow_field".'[3]'."' id='$aow_field".'[3]'."' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_date_type_list'], $value[3]) ."</select>";
596
-    }
597
-    else {
612
+    } else {
598 613
         $field = getDateFields($module, $view, $value[0], $field_option).' '.$app_list_strings['aow_date_operator'][$value[1]];
599 614
         if($value[1] == 'plus' || $value[1] == 'minus'){
600 615
             $field .= ' '.$value[2].' '.$app_list_strings['aow_date_type_list'][$value[3]];
@@ -610,7 +625,9 @@  discard block
 block discarded – undo
610 625
 
611 626
     $fields = $app_list_strings['aow_date_options'];
612 627
 
613
-    if(!$field_option) unset($fields['field']);
628
+    if(!$field_option) {
629
+        unset($fields['field']);
630
+    }
614 631
 
615 632
     if ($module != '') {
616 633
         if(isset($beanList[$module]) && $beanList[$module]){
@@ -643,8 +660,7 @@  discard block
 block discarded – undo
643 660
 
644 661
     if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){
645 662
         unset($app_list_strings['aow_assign_options']['security_group']);
646
-    }
647
-    else{
663
+    } else{
648 664
         $securityGroups = get_bean_select_array(true, 'SecurityGroup','name', '','name',true);
649 665
     }
650 666
 
@@ -654,17 +670,19 @@  discard block
 block discarded – undo
654 670
         $field .= "<select type='text' name='$aow_field".'[0]'."' id='$aow_field".'[0]'."' onchange='assign_field_change(\"$aow_field\")' title='' tabindex='116'>". get_select_options_with_id($app_list_strings['aow_assign_options'], $value[0]) ."</select>&nbsp;&nbsp;";
655 671
         if(!file_exists('modules/SecurityGroups/SecurityGroup.php')){
656 672
             $field .= "<input type='hidden' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' value=''  />";
657
-        }
658
-        else {
673
+        } else {
659 674
             $display = 'none';
660
-            if($value[0] == 'security_group') $display = '';
675
+            if($value[0] == 'security_group') {
676
+                $display = '';
677
+            }
661 678
             $field .= "<select type='text' style='display:$display' name='$aow_field".'[1]'."' id='$aow_field".'[1]'."' title='' tabindex='116'>". get_select_options_with_id($securityGroups, $value[1]) ."</select>&nbsp;&nbsp;";
662 679
         }
663 680
         $display = 'none';
664
-        if($value[0] == 'role' || $value[0] == 'security_group') $display = '';
681
+        if($value[0] == 'role' || $value[0] == 'security_group') {
682
+            $display = '';
683
+        }
665 684
         $field .= "<select type='text' style='display:$display' name='$aow_field".'[2]'."' id='$aow_field".'[2]'."' title='' tabindex='116'>". get_select_options_with_id($roles, $value[2]) ."</select>&nbsp;&nbsp;";
666
-    }
667
-    else {
685
+    } else {
668 686
         $field = $app_list_strings['aow_assign_options'][$value[1]];
669 687
     }
670 688
     return $field;
@@ -679,8 +697,7 @@  discard block
 block discarded – undo
679 697
             $option .= '<option value="'.$key.'" selected>'.$value.'</option>';
680 698
         } else if($selected_value == $key) {
681 699
             $option .= '<option value="'.$key.'" selected>'.$value.'</option>';
682
-        }
683
-        else {
700
+        } else {
684 701
             $option .= '<option value="'.$key.'">'.$value.'</option>';
685 702
         }
686 703
     }
@@ -707,8 +724,7 @@  discard block
 block discarded – undo
707 724
         if(!empty($users[$key])) {
708 725
             return $users[$key];
709 726
         }
710
-    }
711
-    else if (is_file($file)){
727
+    } else if (is_file($file)){
712 728
         require_once($file);
713 729
         if(isset($lastUser['User']) && $lastUser['User'] != '') {
714 730
             $users_by_key = array_flip($users); // now keys are values
@@ -769,7 +785,9 @@  discard block
 block discarded – undo
769 785
             $mod = new $beanList[$module]();
770 786
 
771 787
             foreach($mod->get_related_fields() as $field){
772
-                if(isset($field['link'])) $checked_link[] = $field['link'];
788
+                if(isset($field['link'])) {
789
+                    $checked_link[] = $field['link'];
790
+                }
773 791
                 if(!isset($field['module']) || !in_array($field['module'],$emailableModules) || (isset($field['dbType']) && $field['dbType'] == "id")){
774 792
                     continue;
775 793
                 }
@@ -813,7 +831,9 @@  discard block
 block discarded – undo
813 831
     switch($bean->field_defs[$field]['type']) {
814 832
         case 'datetime':
815 833
         case 'datetimecombo':
816
-            if(empty($value)) break;
834
+            if(empty($value)) {
835
+                break;
836
+            }
817 837
             if ($value == 'NULL') {
818 838
                 $value = '';
819 839
                 break;
@@ -824,7 +844,9 @@  discard block
 block discarded – undo
824 844
             }
825 845
             break;
826 846
         case 'date':
827
-            if(empty($value)) break;
847
+            if(empty($value)) {
848
+                break;
849
+            }
828 850
             if ($value == 'NULL') {
829 851
                 $value = '';
830 852
                 break;
@@ -835,7 +857,9 @@  discard block
 block discarded – undo
835 857
             }
836 858
             break;
837 859
         case 'time':
838
-            if(empty($value)) break;
860
+            if(empty($value)) {
861
+                break;
862
+            }
839 863
             if ($value == 'NULL') {
840 864
                 $value = '';
841 865
                 break;
Please login to merge, or discard this patch.
tests/tests/modules/Project/ProjectTest.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,8 +69,7 @@
 block discarded – undo
69 69
     	try {
70 70
     		$project->save_relationship_changes(true);
71 71
     		$this->assertTrue(true);
72
-    	}
73
-    	catch (Exception $e) {
72
+    	} catch (Exception $e) {
74 73
     		$this->fail();
75 74
     	}
76 75
         	
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -3,132 +3,132 @@  discard block
 block discarded – undo
3 3
 class ProjectTest extends PHPUnit_Framework_TestCase {
4 4
 
5 5
 
6
-	public function testProject()
7
-	{
8
-		//execute the contructor and check for the Object type and  attributes
9
-		$project = new Project();
6
+    public function testProject()
7
+    {
8
+        //execute the contructor and check for the Object type and  attributes
9
+        $project = new Project();
10 10
 
11
-		$this->assertInstanceOf('Project',$project);
12
-		$this->assertInstanceOf('SugarBean',$project);
11
+        $this->assertInstanceOf('Project',$project);
12
+        $this->assertInstanceOf('SugarBean',$project);
13 13
 
14 14
 
15
-		$this->assertAttributeEquals('project', 'table_name', $project);
16
-		$this->assertAttributeEquals('Project', 'module_dir', $project);
17
-		$this->assertAttributeEquals('Project', 'object_name', $project);
15
+        $this->assertAttributeEquals('project', 'table_name', $project);
16
+        $this->assertAttributeEquals('Project', 'module_dir', $project);
17
+        $this->assertAttributeEquals('Project', 'object_name', $project);
18 18
 
19
-		$this->assertAttributeEquals(true, 'new_schema', $project);
19
+        $this->assertAttributeEquals(true, 'new_schema', $project);
20 20
 
21
-	}
21
+    }
22 22
 
23
-	public function testfill_in_additional_detail_fields()
24
-	{
25
-		error_reporting(E_ERROR | E_PARSE);
23
+    public function testfill_in_additional_detail_fields()
24
+    {
25
+        error_reporting(E_ERROR | E_PARSE);
26 26
 
27
-		$project = new Project();
27
+        $project = new Project();
28 28
 
29
-		//test without setting assigned_user_id
30
-		$project->fill_in_additional_detail_fields();
31
-		$this->assertEquals("", $project->assigned_user_name);
29
+        //test without setting assigned_user_id
30
+        $project->fill_in_additional_detail_fields();
31
+        $this->assertEquals("", $project->assigned_user_name);
32 32
 
33 33
 
34
-		//test with assigned_user_id set
35
-		$project->assigned_user_id = 1;
36
-		$project->fill_in_additional_detail_fields();
37
-		$this->assertEquals("Administrator", $project->assigned_user_name);
34
+        //test with assigned_user_id set
35
+        $project->assigned_user_id = 1;
36
+        $project->fill_in_additional_detail_fields();
37
+        $this->assertEquals("Administrator", $project->assigned_user_name);
38 38
 
39
-	}
39
+    }
40 40
 
41 41
 
42
-	public function testfill_in_additional_list_fields()
43
-	{
44
-		$project = new Project();
42
+    public function testfill_in_additional_list_fields()
43
+    {
44
+        $project = new Project();
45 45
 
46
-		//test without setting assigned_user_id
47
-		$project->fill_in_additional_list_fields();
48
-		$this->assertEquals("", $project->assigned_user_name);
46
+        //test without setting assigned_user_id
47
+        $project->fill_in_additional_list_fields();
48
+        $this->assertEquals("", $project->assigned_user_name);
49 49
 
50 50
 
51
-		//test with assigned_user_id set
52
-		$project->assigned_user_id = 1;
53
-		$project->fill_in_additional_list_fields();
54
-		$this->assertEquals("Administrator", $project->assigned_user_name);
51
+        //test with assigned_user_id set
52
+        $project->assigned_user_id = 1;
53
+        $project->fill_in_additional_list_fields();
54
+        $this->assertEquals("Administrator", $project->assigned_user_name);
55 55
 
56
-	}
56
+    }
57 57
 
58 58
 
59 59
     public function testsave_relationship_changes()
60 60
     {
61 61
 
62
-    	$project = new Project();
62
+        $project = new Project();
63 63
 
64
-    	$project->id =1;
65
-    	$_REQUEST['relate_id'] = 2;
66
-    	$_REQUEST['relate_to'] = "contacts";
64
+        $project->id =1;
65
+        $_REQUEST['relate_id'] = 2;
66
+        $_REQUEST['relate_to'] = "contacts";
67 67
 
68
-    	//execute the method and test if it works and does not throws an exception.
69
-    	try {
70
-    		$project->save_relationship_changes(true);
71
-    		$this->assertTrue(true);
72
-    	}
73
-    	catch (Exception $e) {
74
-    		$this->fail();
75
-    	}
68
+        //execute the method and test if it works and does not throws an exception.
69
+        try {
70
+            $project->save_relationship_changes(true);
71
+            $this->assertTrue(true);
72
+        }
73
+        catch (Exception $e) {
74
+            $this->fail();
75
+        }
76 76
 
77 77
     }
78 78
 
79 79
 
80
-	public function test_get_total_estimated_effort()
81
-	{
82
-		//$project = new Project();
83
-		//$result = $project->_get_total_estimated_effort("1");
84
-		$this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given');
80
+    public function test_get_total_estimated_effort()
81
+    {
82
+        //$project = new Project();
83
+        //$result = $project->_get_total_estimated_effort("1");
84
+        $this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given');
85 85
 
86
-	}
86
+    }
87 87
 
88 88
 
89
-	public function test_get_total_actual_effort()
90
-	{
91
-		$this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given');
92
-	}
89
+    public function test_get_total_actual_effort()
90
+    {
91
+        $this->markTestIncomplete('Can Not be implemented: Unknown column parent_id in where clause \n Argument 3 passed to MysqlManager::convert() must be of the type array, integer given');
92
+    }
93 93
 
94 94
 
95
-	public function testget_summary_text()
96
-	{
97
-		$project = new Project();
95
+    public function testget_summary_text()
96
+    {
97
+        $project = new Project();
98 98
 
99
-		//test without setting name
100
-		$this->assertEquals(Null,$project->get_summary_text());
99
+        //test without setting name
100
+        $this->assertEquals(Null,$project->get_summary_text());
101 101
 
102
-		//test with name set
103
-		$project->name = "test";
104
-		$this->assertEquals('test',$project->get_summary_text());
102
+        //test with name set
103
+        $project->name = "test";
104
+        $this->assertEquals('test',$project->get_summary_text());
105 105
 
106
-	}
106
+    }
107 107
 
108 108
 
109
-	public function testbuild_generic_where_clause ()
110
-	{
109
+    public function testbuild_generic_where_clause ()
110
+    {
111 111
 
112
-		$project = new Project();
112
+        $project = new Project();
113 113
 
114
-		//test with empty string params
115
-		$expected = "project.name LIKE '%%'";
116
-		$actual = $project->build_generic_where_clause('');
117
-		$this->assertSame($expected,$actual);
114
+        //test with empty string params
115
+        $expected = "project.name LIKE '%%'";
116
+        $actual = $project->build_generic_where_clause('');
117
+        $this->assertSame($expected,$actual);
118 118
 
119 119
 
120
-		//test with valid string params
121
-		$expected = "project.name LIKE '%%'";
122
-		$actual = $project->build_generic_where_clause('test');
123
-		$this->assertSame($expected,$actual);
120
+        //test with valid string params
121
+        $expected = "project.name LIKE '%%'";
122
+        $actual = $project->build_generic_where_clause('test');
123
+        $this->assertSame($expected,$actual);
124 124
 
125
-	}
125
+    }
126 126
 
127 127
     /**
128 128
      * @todo: NEEDS FIXING!
129 129
      */
130
-	public function testget_list_view_data()
131
-	{
130
+    public function testget_list_view_data()
131
+    {
132 132
         /*
133 133
 		$project = new Project();
134 134
 
@@ -146,44 +146,44 @@  discard block
 block discarded – undo
146 146
 		$this->assertSame($expected, $actual);
147 147
 		*/
148 148
         $this->assertTrue(true, "NEEDS FIXING!");
149
-	}
149
+    }
150 150
 
151
-	public function testbean_implements(){
151
+    public function testbean_implements(){
152 152
 
153
-		$project = new Project();
153
+        $project = new Project();
154 154
 
155
-		$this->assertEquals(false, $project->bean_implements('')); //test with blank value
156
-		$this->assertEquals(false, $project->bean_implements('test')); //test with invalid value
157
-		$this->assertEquals(true, $project->bean_implements('ACL')); //test with valid value
155
+        $this->assertEquals(false, $project->bean_implements('')); //test with blank value
156
+        $this->assertEquals(false, $project->bean_implements('test')); //test with invalid value
157
+        $this->assertEquals(true, $project->bean_implements('ACL')); //test with valid value
158 158
 
159
-	}
159
+    }
160 160
 
161 161
     public function testcreate_export_query()
162 162
     {
163
-    	$project = new Project();
163
+        $project = new Project();
164 164
 
165
-    	//test with empty string params
166
-    	$expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where  project.deleted=0 ";
167
-    	$actual = $project->create_export_query('','');
168
-    	$this->assertSame($expected,$actual);
165
+        //test with empty string params
166
+        $expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where  project.deleted=0 ";
167
+        $actual = $project->create_export_query('','');
168
+        $this->assertSame($expected,$actual);
169 169
 
170 170
 
171
-    	//test with valid string params
172
-    	$expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where (users.user_name) AND  project.deleted=0  ORDER BY project.id";
173
-    	$actual = $project->create_export_query('project.id','users.user_name');
174
-    	$this->assertSame($expected,$actual);
171
+        //test with valid string params
172
+        $expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where (users.user_name) AND  project.deleted=0  ORDER BY project.id";
173
+        $actual = $project->create_export_query('project.id','users.user_name');
174
+        $this->assertSame($expected,$actual);
175 175
 
176 176
     }
177 177
 
178
-	public function testgetAllProjectTasks(){
178
+    public function testgetAllProjectTasks(){
179 179
 
180
-		$project = new Project();
180
+        $project = new Project();
181 181
 
182
-		$project->id = 1;
183
-		$result = $project->getAllProjectTasks();
184
-		$this->assertTrue(is_array($result));
182
+        $project->id = 1;
183
+        $result = $project->getAllProjectTasks();
184
+        $this->assertTrue(is_array($result));
185 185
 
186
-	}
186
+    }
187 187
 
188 188
 }
189 189
 ?>
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 		//execute the contructor and check for the Object type and  attributes
9 9
 		$project = new Project();
10 10
 
11
-		$this->assertInstanceOf('Project',$project);
12
-		$this->assertInstanceOf('SugarBean',$project);
11
+		$this->assertInstanceOf('Project', $project);
12
+		$this->assertInstanceOf('SugarBean', $project);
13 13
 
14 14
 
15 15
 		$this->assertAttributeEquals('project', 'table_name', $project);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
     	$project = new Project();
63 63
 
64
-    	$project->id =1;
64
+    	$project->id = 1;
65 65
     	$_REQUEST['relate_id'] = 2;
66 66
     	$_REQUEST['relate_to'] = "contacts";
67 67
 
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 		$project = new Project();
98 98
 
99 99
 		//test without setting name
100
-		$this->assertEquals(Null,$project->get_summary_text());
100
+		$this->assertEquals(Null, $project->get_summary_text());
101 101
 
102 102
 		//test with name set
103 103
 		$project->name = "test";
104
-		$this->assertEquals('test',$project->get_summary_text());
104
+		$this->assertEquals('test', $project->get_summary_text());
105 105
 
106 106
 	}
107 107
 
108 108
 
109
-	public function testbuild_generic_where_clause ()
109
+	public function testbuild_generic_where_clause()
110 110
 	{
111 111
 
112 112
 		$project = new Project();
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 		//test with empty string params
115 115
 		$expected = "project.name LIKE '%%'";
116 116
 		$actual = $project->build_generic_where_clause('');
117
-		$this->assertSame($expected,$actual);
117
+		$this->assertSame($expected, $actual);
118 118
 
119 119
 
120 120
 		//test with valid string params
121 121
 		$expected = "project.name LIKE '%%'";
122 122
 		$actual = $project->build_generic_where_clause('test');
123
-		$this->assertSame($expected,$actual);
123
+		$this->assertSame($expected, $actual);
124 124
 
125 125
 	}
126 126
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         $this->assertTrue(true, "NEEDS FIXING!");
149 149
 	}
150 150
 
151
-	public function testbean_implements(){
151
+	public function testbean_implements() {
152 152
 
153 153
 		$project = new Project();
154 154
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 
165 165
     	//test with empty string params
166 166
     	$expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where  project.deleted=0 ";
167
-    	$actual = $project->create_export_query('','');
168
-    	$this->assertSame($expected,$actual);
167
+    	$actual = $project->create_export_query('', '');
168
+    	$this->assertSame($expected, $actual);
169 169
 
170 170
 
171 171
     	//test with valid string params
172 172
     	$expected = "SELECT\n				project.*,\n                users.user_name as assigned_user_name ,project_cstm.jjwg_maps_lng_c,project_cstm.jjwg_maps_lat_c,project_cstm.jjwg_maps_geocode_status_c,project_cstm.jjwg_maps_address_c FROM project  LEFT JOIN project_cstm ON project.id = project_cstm.id_c  LEFT JOIN users\n                   	ON project.assigned_user_id=users.id where (users.user_name) AND  project.deleted=0  ORDER BY project.id";
173
-    	$actual = $project->create_export_query('project.id','users.user_name');
174
-    	$this->assertSame($expected,$actual);
173
+    	$actual = $project->create_export_query('project.id', 'users.user_name');
174
+    	$this->assertSame($expected, $actual);
175 175
 
176 176
     }
177 177
 
178
-	public function testgetAllProjectTasks(){
178
+	public function testgetAllProjectTasks() {
179 179
 
180 180
 		$project = new Project();
181 181
 
Please login to merge, or discard this patch.
tests/tests/modules/Users/UserTest.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -221,8 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$user->savePreferencesToDB();
223 223
 			$this->assertTrue(true);
224
-		}
225
-		catch (Exception $e) {
224
+		} catch (Exception $e) {
226 225
 			$this->fail();
227 226
 		}
228 227
 		
@@ -1095,8 +1094,7 @@  discard block
 block discarded – undo
1095 1094
     	try {
1096 1095
     		$result = $user->afterImportSave();
1097 1096
     		$this->assertTrue(true);
1098
-    	}
1099
-    	catch (Exception $e) {
1097
+    	} catch (Exception $e) {
1100 1098
     		$this->assertStringStartsWith('Cannot modify header information', $e->getMessage());
1101 1099
     	}
1102 1100
     	
Please login to merge, or discard this patch.
Indentation   +642 added lines, -642 removed lines patch added patch discarded remove patch
@@ -4,976 +4,976 @@  discard block
 block discarded – undo
4 4
 class UserTest extends PHPUnit_Framework_TestCase {
5 5
 
6 6
 
7
-	public function testUser() {
7
+    public function testUser() {
8 8
 
9
-		//execute the contructor and check for the Object type and  attributes
10
-		$user = new User();
9
+        //execute the contructor and check for the Object type and  attributes
10
+        $user = new User();
11 11
 
12
-		$this->assertInstanceOf('User',$user);
13
-		$this->assertInstanceOf('Person',$user);
14
-		$this->assertInstanceOf('SugarBean',$user);
12
+        $this->assertInstanceOf('User',$user);
13
+        $this->assertInstanceOf('Person',$user);
14
+        $this->assertInstanceOf('SugarBean',$user);
15 15
 
16
-		$this->assertAttributeEquals('Users', 'module_dir', $user);
17
-		$this->assertAttributeEquals('User', 'object_name', $user);
18
-		$this->assertAttributeEquals('users', 'table_name', $user);
16
+        $this->assertAttributeEquals('Users', 'module_dir', $user);
17
+        $this->assertAttributeEquals('User', 'object_name', $user);
18
+        $this->assertAttributeEquals('users', 'table_name', $user);
19 19
 
20
-		$this->assertAttributeEquals(true, 'new_schema', $user);
21
-		$this->assertAttributeEquals(false, 'authenticated', $user);
22
-		$this->assertAttributeEquals(true, 'importable', $user);
23
-		$this->assertAttributeEquals(false, 'team_exists', $user);
20
+        $this->assertAttributeEquals(true, 'new_schema', $user);
21
+        $this->assertAttributeEquals(false, 'authenticated', $user);
22
+        $this->assertAttributeEquals(true, 'importable', $user);
23
+        $this->assertAttributeEquals(false, 'team_exists', $user);
24 24
 
25
-	}
25
+    }
26 26
 
27 27
 
28 28
     public function testgetSystemUser()
29 29
     {
30
-    	//unset and reconnect Db to resolve mysqli fetch exeception
31
-    	global $db;
32
-    	unset ($db->database);
33
-    	$db->checkConnection();
30
+        //unset and reconnect Db to resolve mysqli fetch exeception
31
+        global $db;
32
+        unset ($db->database);
33
+        $db->checkConnection();
34 34
 
35
-    	$user = new User();
35
+        $user = new User();
36 36
 
37
-    	$result = $user->getSystemUser();
37
+        $result = $user->getSystemUser();
38 38
 
39
-    	$this->assertInstanceOf('User',$result);
40
-    	$this->assertEquals(1, $result->id);
39
+        $this->assertInstanceOf('User',$result);
40
+        $this->assertEquals(1, $result->id);
41 41
 
42 42
     }
43 43
 
44 44
 
45
-	public function testgetDefaultSignature()
46
-	{
47
-		//unset and reconnect Db to resolve mysqli fetch exeception
48
-		global $db;
49
-		unset ($db->database);
50
-		$db->checkConnection();
45
+    public function testgetDefaultSignature()
46
+    {
47
+        //unset and reconnect Db to resolve mysqli fetch exeception
48
+        global $db;
49
+        unset ($db->database);
50
+        $db->checkConnection();
51 51
 
52
-		$user = new User();
52
+        $user = new User();
53 53
 
54
-		$user->retrieve(1);
54
+        $user->retrieve(1);
55 55
 
56
-		$result = $user->getDefaultSignature();
57
-		$this->assertTrue(is_array($result));
56
+        $result = $user->getDefaultSignature();
57
+        $this->assertTrue(is_array($result));
58 58
 
59
-	}
59
+    }
60 60
 
61 61
 
62
-	public function testgetSignature()
63
-	{
64
-		$user = new User();
62
+    public function testgetSignature()
63
+    {
64
+        $user = new User();
65 65
 
66
-		$user->retrieve(1);
66
+        $user->retrieve(1);
67 67
 
68
-		$result = $user->getSignature(1);
69
-		$this->assertEquals(false,$result);
68
+        $result = $user->getSignature(1);
69
+        $this->assertEquals(false,$result);
70 70
 
71
-	}
71
+    }
72 72
 
73
-	public function testgetSignaturesArray() {
73
+    public function testgetSignaturesArray() {
74 74
 
75
-		$user = new User();
75
+        $user = new User();
76 76
 
77
-		$user->retrieve(1);
77
+        $user->retrieve(1);
78 78
 
79
-		$result = $user->getSignaturesArray();
80
-		$this->assertTrue(is_array($result));
79
+        $result = $user->getSignaturesArray();
80
+        $this->assertTrue(is_array($result));
81 81
 
82
-	}
82
+    }
83 83
 
84 84
 
85
-	public function testgetSignatures()
86
-	{
87
-		$user = new User();
85
+    public function testgetSignatures()
86
+    {
87
+        $user = new User();
88 88
 
89
-		$user->retrieve(1);
89
+        $user->retrieve(1);
90 90
 
91
-		$expected = "<select onChange='setSigEditButtonVisibility();' id='signature_id' name='signature_id'>\n<OPTION selected value=''>--None--</OPTION></select>";
92
-		$actual = $user->getSignatures();
93
-		$this->assertSame($expected, $actual);
91
+        $expected = "<select onChange='setSigEditButtonVisibility();' id='signature_id' name='signature_id'>\n<OPTION selected value=''>--None--</OPTION></select>";
92
+        $actual = $user->getSignatures();
93
+        $this->assertSame($expected, $actual);
94 94
 
95
-	}
95
+    }
96 96
 
97 97
 
98
-	public function testgetSignatureButtons()
99
-	{
98
+    public function testgetSignatureButtons()
99
+    {
100 100
 
101
-		global $mod_strings;
101
+        global $mod_strings;
102 102
 
103
-		$user = new User();
103
+        $user = new User();
104 104
 
105
-		//preset required values
106
-		$user->retrieve(1);
107
-		$mod_strings['LBL_BUTTON_EDIT'] = "";
108
-		$mod_strings['LBL_BUTTON_CREATE'] = "";
105
+        //preset required values
106
+        $user->retrieve(1);
107
+        $mod_strings['LBL_BUTTON_EDIT'] = "";
108
+        $mod_strings['LBL_BUTTON_CREATE'] = "";
109 109
 
110 110
 
111
-		//test with defaultDisplay false
112
-		$expected = "<input class='button' onclick='javascript:open_email_signature_form(\"\", \"1\");' value='' type='button'>&nbsp;<span name=\"edit_sig\" id=\"edit_sig\" style=\"visibility:hidden;\"><input class=\"button\" onclick=\"javascript:open_email_signature_form(document.getElementById('signature_id', '').value)\" value=\"\" type=\"button\" tabindex=\"392\">&nbsp;\n					</span>";
113
-		$actual = $user->getSignatureButtons('');
114
-		$this->assertSame($expected, $actual);
111
+        //test with defaultDisplay false
112
+        $expected = "<input class='button' onclick='javascript:open_email_signature_form(\"\", \"1\");' value='' type='button'>&nbsp;<span name=\"edit_sig\" id=\"edit_sig\" style=\"visibility:hidden;\"><input class=\"button\" onclick=\"javascript:open_email_signature_form(document.getElementById('signature_id', '').value)\" value=\"\" type=\"button\" tabindex=\"392\">&nbsp;\n					</span>";
113
+        $actual = $user->getSignatureButtons('');
114
+        $this->assertSame($expected, $actual);
115 115
 
116 116
 
117
-		//test with defaultDisplay true
118
-		$expected = "<input class='button' onclick='javascript:open_email_signature_form(\"\", \"1\");' value='' type='button'>&nbsp;<span name=\"edit_sig\" id=\"edit_sig\" style=\"visibility:inherit;\"><input class=\"button\" onclick=\"javascript:open_email_signature_form(document.getElementById('signature_id', '').value)\" value=\"\" type=\"button\" tabindex=\"392\">&nbsp;\n					</span>";
119
-		$actual = $user->getSignatureButtons('',true);
120
-		$this->assertSame($expected, $actual);
117
+        //test with defaultDisplay true
118
+        $expected = "<input class='button' onclick='javascript:open_email_signature_form(\"\", \"1\");' value='' type='button'>&nbsp;<span name=\"edit_sig\" id=\"edit_sig\" style=\"visibility:inherit;\"><input class=\"button\" onclick=\"javascript:open_email_signature_form(document.getElementById('signature_id', '').value)\" value=\"\" type=\"button\" tabindex=\"392\">&nbsp;\n					</span>";
119
+        $actual = $user->getSignatureButtons('',true);
120
+        $this->assertSame($expected, $actual);
121 121
 
122
-	}
122
+    }
123 123
 
124 124
 
125
-	public function testhasPersonalEmail()
126
-	{
125
+    public function testhasPersonalEmail()
126
+    {
127 127
 
128
-		$user = new User();
128
+        $user = new User();
129 129
 
130
-		$user->retrieve(2);
130
+        $user->retrieve(2);
131 131
 
132
-		$result = $user->hasPersonalEmail();
133
-		$this->assertEquals(false,$result);
132
+        $result = $user->hasPersonalEmail();
133
+        $this->assertEquals(false,$result);
134 134
 
135
-	}
135
+    }
136 136
 
137 137
 
138
-	public function testgetUserPrivGuid()
139
-	{
140
-		//unset and reconnect Db to resolve mysqli fetch exeception
141
-		global $db;
142
-		unset ($db->database);
143
-		$db->checkConnection();
138
+    public function testgetUserPrivGuid()
139
+    {
140
+        //unset and reconnect Db to resolve mysqli fetch exeception
141
+        global $db;
142
+        unset ($db->database);
143
+        $db->checkConnection();
144 144
 
145
-		$user = new User();
145
+        $user = new User();
146 146
 
147
-		$user->retrieve(1);
147
+        $user->retrieve(1);
148 148
 
149
-		$result = $user->getUserPrivGuid();
149
+        $result = $user->getUserPrivGuid();
150 150
 
151
-		$this->assertTrue(isset($result));
152
-		$this->assertEquals(36, strlen($result));
151
+        $this->assertTrue(isset($result));
152
+        $this->assertEquals(36, strlen($result));
153 153
 
154
-	}
154
+    }
155 155
 
156
-	public function testsetUserPrivGuid()
157
-	{
158
-		//unset and reconnect Db to resolve mysqli fetch exeception
159
-		global $db;
160
-		unset ($db->database);
161
-		$db->checkConnection();
156
+    public function testsetUserPrivGuid()
157
+    {
158
+        //unset and reconnect Db to resolve mysqli fetch exeception
159
+        global $db;
160
+        unset ($db->database);
161
+        $db->checkConnection();
162 162
 
163 163
 
164
-		$user = new User();
164
+        $user = new User();
165 165
 
166
-		$user->retrieve(1);
166
+        $user->retrieve(1);
167 167
 
168
-		$user->setUserPrivGuid();
168
+        $user->setUserPrivGuid();
169 169
 
170
-		$result = $user->getPreference('userPrivGuid', 'global', $user);
170
+        $result = $user->getPreference('userPrivGuid', 'global', $user);
171 171
 
172
-		$this->assertTrue(isset($result));
173
-		$this->assertEquals(36, strlen($result));
172
+        $this->assertTrue(isset($result));
173
+        $this->assertEquals(36, strlen($result));
174 174
 
175
-	}
175
+    }
176 176
 
177
-	public function testSetAndGetAndResetPreference( )
178
-	{
179
-		//unset and reconnect Db to resolve mysqli fetch exeception
180
-		global $db;
181
-		unset ($db->database);
182
-		$db->checkConnection();
177
+    public function testSetAndGetAndResetPreference( )
178
+    {
179
+        //unset and reconnect Db to resolve mysqli fetch exeception
180
+        global $db;
181
+        unset ($db->database);
182
+        $db->checkConnection();
183 183
 
184
-		$user = new User();
184
+        $user = new User();
185 185
 
186
-		$user->retrieve(1);
186
+        $user->retrieve(1);
187 187
 
188 188
 
189
-		//test setPreference method
190
-		$user->setPreference('userPrivGuid', 'someGuid', 0, 'global', $user);
189
+        //test setPreference method
190
+        $user->setPreference('userPrivGuid', 'someGuid', 0, 'global', $user);
191 191
 
192 192
 
193
-		//test getPreference method
194
-		$result = $user->getPreference('userPrivGuid', 'global', $user);
195
-		$this->assertTrue(isset($result));
196
-		$this->assertEquals('someGuid', $result);
193
+        //test getPreference method
194
+        $result = $user->getPreference('userPrivGuid', 'global', $user);
195
+        $this->assertTrue(isset($result));
196
+        $this->assertEquals('someGuid', $result);
197 197
 
198 198
 
199
-		//test resetPreferences method and verify that created preference is no longer available
200
-		$user->resetPreferences();
201
-		$result = $user->getPreference('userPrivGuid', 'global', $user);
202
-		$this->assertFalse(isset($result));
199
+        //test resetPreferences method and verify that created preference is no longer available
200
+        $user->resetPreferences();
201
+        $result = $user->getPreference('userPrivGuid', 'global', $user);
202
+        $this->assertFalse(isset($result));
203 203
 
204
-	}
204
+    }
205 205
 
206 206
 
207 207
 
208 208
 
209
-	public function testsavePreferencesToDB()
210
-	{
211
-		//unset and reconnect Db to resolve mysqli fetch exeception
212
-		global $db;
213
-		unset ($db->database);
214
-		$db->checkConnection();
209
+    public function testsavePreferencesToDB()
210
+    {
211
+        //unset and reconnect Db to resolve mysqli fetch exeception
212
+        global $db;
213
+        unset ($db->database);
214
+        $db->checkConnection();
215 215
 
216
-		$user = new User();
216
+        $user = new User();
217 217
 
218
-		$user->retrieve(1);
218
+        $user->retrieve(1);
219 219
 
220
-		//execute the method and test if it works and does not throws an exception.
221
-		try {
222
-			$user->savePreferencesToDB();
223
-			$this->assertTrue(true);
224
-		}
225
-		catch (Exception $e) {
226
-			$this->fail();
227
-		}
220
+        //execute the method and test if it works and does not throws an exception.
221
+        try {
222
+            $user->savePreferencesToDB();
223
+            $this->assertTrue(true);
224
+        }
225
+        catch (Exception $e) {
226
+            $this->fail();
227
+        }
228 228
 
229
-	}
229
+    }
230 230
 
231 231
 
232
-	public function testreloadPreferences()
233
-	{
234
-		//unset and reconnect Db to resolve mysqli fetch exeception
235
-		global $db;
236
-		unset ($db->database);
237
-		$db->checkConnection();
232
+    public function testreloadPreferences()
233
+    {
234
+        //unset and reconnect Db to resolve mysqli fetch exeception
235
+        global $db;
236
+        unset ($db->database);
237
+        $db->checkConnection();
238 238
 
239
-		$user = new User();
239
+        $user = new User();
240 240
 
241
-		$user->retrieve(1);
241
+        $user->retrieve(1);
242 242
 
243
-		$result = $user->reloadPreferences();
244
-		$this->assertEquals(true, $result);
243
+        $result = $user->reloadPreferences();
244
+        $this->assertEquals(true, $result);
245 245
 
246
-	}
246
+    }
247 247
 
248 248
 
249
-	public function testgetUserDateTimePreferences()
250
-	{
251
-		//unset and reconnect Db to resolve mysqli fetch exeception
252
-		global $db;
253
-		unset ($db->database);
254
-		$db->checkConnection();
249
+    public function testgetUserDateTimePreferences()
250
+    {
251
+        //unset and reconnect Db to resolve mysqli fetch exeception
252
+        global $db;
253
+        unset ($db->database);
254
+        $db->checkConnection();
255 255
 
256
-		$user = new User();
256
+        $user = new User();
257 257
 
258
-		$user->retrieve(1);
258
+        $user->retrieve(1);
259 259
 
260
-		$result = $user->getUserDateTimePreferences();
260
+        $result = $user->getUserDateTimePreferences();
261 261
 
262
-		$this->assertTrue(is_array($result));
263
-		$this->assertTrue(isset($result['date']));
264
-		$this->assertTrue(isset($result['time']));
265
-		$this->assertTrue(isset($result['userGmt']));
266
-		$this->assertTrue(isset($result['userGmtOffset']));
262
+        $this->assertTrue(is_array($result));
263
+        $this->assertTrue(isset($result['date']));
264
+        $this->assertTrue(isset($result['time']));
265
+        $this->assertTrue(isset($result['userGmt']));
266
+        $this->assertTrue(isset($result['userGmtOffset']));
267 267
 
268
-	}
268
+    }
269 269
 
270 270
 
271
-	public function testloadPreferences( )
272
-	{
273
-		//unset and reconnect Db to resolve mysqli fetch exeception
274
-		global $db;
275
-		unset ($db->database);
276
-		$db->checkConnection();
271
+    public function testloadPreferences( )
272
+    {
273
+        //unset and reconnect Db to resolve mysqli fetch exeception
274
+        global $db;
275
+        unset ($db->database);
276
+        $db->checkConnection();
277 277
 
278
-		$user = new User();
278
+        $user = new User();
279 279
 
280
-		$user->retrieve(1);
280
+        $user->retrieve(1);
281 281
 
282
-		$result = $user->loadPreferences();
283
-		$this->assertEquals(true, $result);
282
+        $result = $user->loadPreferences();
283
+        $this->assertEquals(true, $result);
284 284
 
285
-	}
285
+    }
286 286
 
287 287
 
288 288
     public function testGetETagSeedAndIncrementETag(){
289 289
 
290
-    	//unset and reconnect Db to resolve mysqli fetch exeception
291
-    	global $db;
292
-    	unset ($db->database);
293
-    	$db->checkConnection();
290
+        //unset and reconnect Db to resolve mysqli fetch exeception
291
+        global $db;
292
+        unset ($db->database);
293
+        $db->checkConnection();
294 294
 
295
-    	$user = new User();
295
+        $user = new User();
296 296
 
297
-    	$user->retrieve(1);
297
+        $user->retrieve(1);
298 298
 
299
-    	//execute getETagSeed method, get Etag value
300
-    	$ETagInitial = $user->getETagSeed('test');
301
-    	$this->assertGreaterThanOrEqual(0,$ETagInitial);
299
+        //execute getETagSeed method, get Etag value
300
+        $ETagInitial = $user->getETagSeed('test');
301
+        $this->assertGreaterThanOrEqual(0,$ETagInitial);
302 302
 
303 303
 
304
-    	//execute incrementETag to increment
305
-    	$user->incrementETag('test');
304
+        //execute incrementETag to increment
305
+        $user->incrementETag('test');
306 306
 
307 307
 
308
-    	//execute getETagSeed method again, get Etag final value and  compare final and initial values
309
-    	$ETagFinal = $user->getETagSeed('test');
310
-    	$this->assertGreaterThan($ETagInitial, $ETagFinal);
308
+        //execute getETagSeed method again, get Etag final value and  compare final and initial values
309
+        $ETagFinal = $user->getETagSeed('test');
310
+        $this->assertGreaterThan($ETagInitial, $ETagFinal);
311 311
 
312 312
     }
313 313
 
314 314
 
315 315
 
316
-	public function testgetLicensedUsersWhere()
317
-	{
318
-		$expected = "deleted=0 AND status='Active' AND user_name IS NOT NULL AND is_group=0 AND portal_only=0  AND LENGTH(user_name)>0";
319
-		$actual = User::getLicensedUsersWhere();
320
-		$this->assertSame($expected, $actual);
316
+    public function testgetLicensedUsersWhere()
317
+    {
318
+        $expected = "deleted=0 AND status='Active' AND user_name IS NOT NULL AND is_group=0 AND portal_only=0  AND LENGTH(user_name)>0";
319
+        $actual = User::getLicensedUsersWhere();
320
+        $this->assertSame($expected, $actual);
321 321
 
322
-	}
322
+    }
323 323
 
324 324
     public function testget_summary_text()
325 325
     {
326
-    	$user = new User();
326
+        $user = new User();
327 327
 
328
-    	//test without setting name
329
-    	$this->assertEquals(Null,$user->get_summary_text());
328
+        //test without setting name
329
+        $this->assertEquals(Null,$user->get_summary_text());
330 330
 
331
-    	//test with name set
332
-    	$user->name = "test";
333
-    	$this->assertEquals('test',$user->get_summary_text());
331
+        //test with name set
332
+        $user->name = "test";
333
+        $this->assertEquals('test',$user->get_summary_text());
334 334
 
335
-	}
335
+    }
336 336
 
337
-	public function testbean_implements()
338
-	{
339
-		$user = new User();
337
+    public function testbean_implements()
338
+    {
339
+        $user = new User();
340 340
 
341
-		$this->assertEquals(false, $user->bean_implements('')); //test with blank value
342
-		$this->assertEquals(false, $user->bean_implements('test')); //test with invalid value
343
-		$this->assertEquals(true, $user->bean_implements('ACL')); //test with valid value
344
-	}
341
+        $this->assertEquals(false, $user->bean_implements('')); //test with blank value
342
+        $this->assertEquals(false, $user->bean_implements('test')); //test with invalid value
343
+        $this->assertEquals(true, $user->bean_implements('ACL')); //test with valid value
344
+    }
345 345
 
346 346
 
347
-	public function testcheck_role_membership()
348
-	{
349
-		//unset and reconnect Db to resolve mysqli fetch exeception
350
-		global $db;
351
-		unset ($db->database);
352
-		$db->checkConnection();
347
+    public function testcheck_role_membership()
348
+    {
349
+        //unset and reconnect Db to resolve mysqli fetch exeception
350
+        global $db;
351
+        unset ($db->database);
352
+        $db->checkConnection();
353 353
 
354
-		$user = new User();
354
+        $user = new User();
355 355
 
356
-		$result = $user->check_role_membership("test", '');
357
-		$this->assertEquals(false, $result);
356
+        $result = $user->check_role_membership("test", '');
357
+        $this->assertEquals(false, $result);
358 358
 
359 359
 
360
-		$result = $user->check_role_membership("test", '1');
361
-		$this->assertEquals(false, $result);
360
+        $result = $user->check_role_membership("test", '1');
361
+        $this->assertEquals(false, $result);
362 362
 
363
-	}
363
+    }
364 364
 
365 365
 
366
-	public function testsaveAndOthers()
367
-	{
368
-		error_reporting(E_ERROR | E_PARSE);
366
+    public function testsaveAndOthers()
367
+    {
368
+        error_reporting(E_ERROR | E_PARSE);
369 369
 
370
-		//unset and reconnect Db to resolve mysqli fetch exeception
371
-		global $db;
372
-		unset ($db->database);
373
-		$db->checkConnection();
370
+        //unset and reconnect Db to resolve mysqli fetch exeception
371
+        global $db;
372
+        unset ($db->database);
373
+        $db->checkConnection();
374 374
 
375 375
 
376
-		$user = new User();
376
+        $user = new User();
377 377
 
378
-		$user->user_name  = "test";
378
+        $user->user_name  = "test";
379 379
 
380
-		$user->first_name  = "firstn";
381
-		$user->last_name  = "lastn";
380
+        $user->first_name  = "firstn";
381
+        $user->last_name  = "lastn";
382 382
 
383
-		$user->email1 = "[email protected]";
384
-		$user->email2 = "[email protected]";
383
+        $user->email1 = "[email protected]";
384
+        $user->email2 = "[email protected]";
385 385
 
386
-		$result = $user->save();
386
+        $result = $user->save();
387 387
 
388
-		//test for record ID to verify that record is saved
389
-		$this->assertTrue(isset($user->id));
390
-		$this->assertEquals(36, strlen($user->id));
388
+        //test for record ID to verify that record is saved
389
+        $this->assertTrue(isset($user->id));
390
+        $this->assertEquals(36, strlen($user->id));
391 391
 
392 392
 
393
-		//test retrieve method
394
-		$this->retrieve($user->id);
393
+        //test retrieve method
394
+        $this->retrieve($user->id);
395 395
 
396 396
 
397
-		//test retrieve_by_email_address method
398
-		$this->retrieve_by_email_address($user->id);
397
+        //test retrieve_by_email_address method
398
+        $this->retrieve_by_email_address($user->id);
399 399
 
400 400
 
401
-		//test newPassword And findUserPassword methods
402
-		$this->NewPasswordAndFindUserPassword($user->id);
401
+        //test newPassword And findUserPassword methods
402
+        $this->NewPasswordAndFindUserPassword($user->id);
403 403
 
404 404
 
405
-		//test authenticate_user method
406
-		$this->authenticate_user($user->id);
405
+        //test authenticate_user method
406
+        $this->authenticate_user($user->id);
407 407
 
408 408
 
409
-		//test load_user method
410
-		$this->load_user($user->id);
409
+        //test load_user method
410
+        $this->load_user($user->id);
411 411
 
412 412
 
413
-		//test change_password method
414
-		$this->change_password($user->id);
413
+        //test change_password method
414
+        $this->change_password($user->id);
415 415
 
416 416
 
417
-		//test getPreferredEmail method
418
-		$this->getPreferredEmail($user->id);
417
+        //test getPreferredEmail method
418
+        $this->getPreferredEmail($user->id);
419 419
 
420 420
 
421
-		//test getUsersNameAndEmail method
422
-		$this->getUsersNameAndEmail($user->id);
421
+        //test getUsersNameAndEmail method
422
+        $this->getUsersNameAndEmail($user->id);
423 423
 
424 424
 
425
-		//test getEmailInfo method
426
-		$this->getEmailInfo($user->id);
425
+        //test getEmailInfo method
426
+        $this->getEmailInfo($user->id);
427 427
 
428 428
 
429
-		//change username and delete the user to avoid picking it up by password in future
430
-		$user->user_name  = "test_deleted";
431
-		$user->save();
432
-		$user->mark_deleted($user->id);
429
+        //change username and delete the user to avoid picking it up by password in future
430
+        $user->user_name  = "test_deleted";
431
+        $user->save();
432
+        $user->mark_deleted($user->id);
433 433
 
434
-	}
434
+    }
435 435
 
436
-	public function retrieve($id)
437
-	{
438
-		$user = new User();
436
+    public function retrieve($id)
437
+    {
438
+        $user = new User();
439 439
 
440
-		$user->retrieve($id);
440
+        $user->retrieve($id);
441 441
 
442
-		$this->assertEquals("test", $user->user_name);
442
+        $this->assertEquals("test", $user->user_name);
443 443
 
444
-		$this->assertEquals("firstn", $user->first_name);
445
-		$this->assertEquals("lastn", $user->last_name);
444
+        $this->assertEquals("firstn", $user->first_name);
445
+        $this->assertEquals("lastn", $user->last_name);
446 446
 
447
-		$this->assertEquals("[email protected]", $user->email1);
448
-		$this->assertEquals("[email protected]", $user->email2);
447
+        $this->assertEquals("[email protected]", $user->email1);
448
+        $this->assertEquals("[email protected]", $user->email2);
449 449
 
450
-	}
450
+    }
451 451
 
452
-	public function retrieve_by_email_address($id)
453
-	{
454
-		$user = new User();
452
+    public function retrieve_by_email_address($id)
453
+    {
454
+        $user = new User();
455 455
 
456
-		//test with invalid email
457
-		$user->retrieve_by_email_address("[email protected]");
458
-		$this->assertEquals('', $user->id);
456
+        //test with invalid email
457
+        $user->retrieve_by_email_address("[email protected]");
458
+        $this->assertEquals('', $user->id);
459 459
 
460 460
 
461
-		//test with valid email and test for record ID to verify that record is same
462
-		$user->retrieve_by_email_address("[email protected]");
463
-		$this->assertTrue(isset($user->id));
464
-		$this->assertEquals($id, $user->id);
461
+        //test with valid email and test for record ID to verify that record is same
462
+        $user->retrieve_by_email_address("[email protected]");
463
+        $this->assertTrue(isset($user->id));
464
+        $this->assertEquals($id, $user->id);
465 465
 
466
-	}
466
+    }
467 467
 
468
-	public function NewPasswordAndFindUserPassword($id)
469
-	{
470
-		$user = new User();
468
+    public function NewPasswordAndFindUserPassword($id)
469
+    {
470
+        $user = new User();
471 471
 
472
-		$user->retrieve($id);
472
+        $user->retrieve($id);
473 473
 
474
-		//set user password and then retrieve user by created password
475
-		$user->setNewPassword("test");
474
+        //set user password and then retrieve user by created password
475
+        $user->setNewPassword("test");
476 476
 
477
-		$result = User::findUserPassword("test",md5("test"));
477
+        $result = User::findUserPassword("test",md5("test"));
478 478
 
479
-		$this->assertTrue(isset($result['id']));
480
-		$this->assertEquals($id, $result['id']);
479
+        $this->assertTrue(isset($result['id']));
480
+        $this->assertEquals($id, $result['id']);
481 481
 
482
-	}
482
+    }
483 483
 
484 484
 
485
-	public function authenticate_user($id)
486
-	{
487
-		$user = new User();
485
+    public function authenticate_user($id)
486
+    {
487
+        $user = new User();
488 488
 
489
-		$user->retrieve($id);
489
+        $user->retrieve($id);
490 490
 
491
-		//test with invalid password
492
-		$result = $user->authenticate_user(md5("pass"));
493
-		$this->assertEquals(false ,$result);
491
+        //test with invalid password
492
+        $result = $user->authenticate_user(md5("pass"));
493
+        $this->assertEquals(false ,$result);
494 494
 
495
-		//test with invalid password
496
-		$result = $user->authenticate_user(md5("test"));
497
-		$this->assertEquals(true ,$result);
495
+        //test with invalid password
496
+        $result = $user->authenticate_user(md5("test"));
497
+        $this->assertEquals(true ,$result);
498 498
 
499
-	}
499
+    }
500 500
 
501 501
 
502
-	public function load_user($id)
503
-	{
504
-		$user = new User();
502
+    public function load_user($id)
503
+    {
504
+        $user = new User();
505 505
 
506
-		$user->retrieve($id);
506
+        $user->retrieve($id);
507 507
 
508
-		$result = $user->load_user("test");
508
+        $result = $user->load_user("test");
509 509
 
510
-		$this->assertEquals(true, $result->authenticated);
510
+        $this->assertEquals(true, $result->authenticated);
511 511
 
512
-	}
512
+    }
513 513
 
514
-	public function change_password($id)
515
-	{
516
-		$user = new User();
514
+    public function change_password($id)
515
+    {
516
+        $user = new User();
517 517
 
518
-		$user->retrieve($id);
518
+        $user->retrieve($id);
519 519
 
520
-		//execute the method and verifh that it returns true
521
-		$result = $user->change_password("test", "testpass");
522
-		$this->assertEquals(true, $result);
520
+        //execute the method and verifh that it returns true
521
+        $result = $user->change_password("test", "testpass");
522
+        $this->assertEquals(true, $result);
523 523
 
524 524
 
525
-		//find the user by new password
526
-		$result = User::findUserPassword("test",md5("testpass"));
525
+        //find the user by new password
526
+        $result = User::findUserPassword("test",md5("testpass"));
527 527
 
528
-		$this->assertTrue(isset($result['id']));
529
-		$this->assertEquals($id, $result['id']);
528
+        $this->assertTrue(isset($result['id']));
529
+        $this->assertEquals($id, $result['id']);
530 530
 
531
-	}
531
+    }
532 532
 
533
-	public function getPreferredEmail($id)
534
-	{
535
-		$user = new User();
533
+    public function getPreferredEmail($id)
534
+    {
535
+        $user = new User();
536 536
 
537
-		$user->retrieve($id);
537
+        $user->retrieve($id);
538 538
 
539
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
539
+        $expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
540 540
 
541
-		$actual = $user->getPreferredEmail();
541
+        $actual = $user->getPreferredEmail();
542 542
 
543
-		$this->assertSame($actual,$expected);
543
+        $this->assertSame($actual,$expected);
544 544
 
545
-	}
545
+    }
546 546
 
547
-	public function getUsersNameAndEmail($id)
548
-	{
549
-		$user = new User();
547
+    public function getUsersNameAndEmail($id)
548
+    {
549
+        $user = new User();
550 550
 
551
-		$user->retrieve($id);
551
+        $user->retrieve($id);
552 552
 
553
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
553
+        $expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
554 554
 
555
-		$actual = $user->getUsersNameAndEmail();
555
+        $actual = $user->getUsersNameAndEmail();
556 556
 
557
-		$this->assertEquals($actual,$expected);
558
-	}
557
+        $this->assertEquals($actual,$expected);
558
+    }
559 559
 
560 560
 
561
-	public function getEmailInfo($id)
562
-	{
563
-		$user = new User();
561
+    public function getEmailInfo($id)
562
+    {
563
+        $user = new User();
564 564
 
565
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
565
+        $expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
566 566
 
567
-		$actual = $user->getEmailInfo($id);
567
+        $actual = $user->getEmailInfo($id);
568 568
 
569
-		$this->assertEquals($actual,$expected);
570
-	}
569
+        $this->assertEquals($actual,$expected);
570
+    }
571 571
 
572 572
 
573
-	public function testencrypt_password()
574
-	{
575
-		$user = new User();
573
+    public function testencrypt_password()
574
+    {
575
+        $user = new User();
576 576
 
577
-		$result = $user->encrypt_password("test");
578
-		$this->assertTrue(isset($result));
579
-		$this->assertGreaterThan(0,strlen($result));
577
+        $result = $user->encrypt_password("test");
578
+        $this->assertTrue(isset($result));
579
+        $this->assertGreaterThan(0,strlen($result));
580 580
 
581
-	}
581
+    }
582 582
 
583
-	public function testgetPasswordHash()
584
-	{
583
+    public function testgetPasswordHash()
584
+    {
585 585
 
586
-		$result= User::getPasswordHash("test");
586
+        $result= User::getPasswordHash("test");
587 587
 
588
-		$this->assertTrue(isset($result));
589
-		$this->assertGreaterThan(0,strlen($result));
588
+        $this->assertTrue(isset($result));
589
+        $this->assertGreaterThan(0,strlen($result));
590 590
 
591
-		$this->markTestIncomplete('Error: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash.');
591
+        $this->markTestIncomplete('Error: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash.');
592 592
 
593
-	}
593
+    }
594 594
 
595 595
 
596
-	public function testcheckPassword()
597
-	{
596
+    public function testcheckPassword()
597
+    {
598 598
 
599
-		//test with empty password and empty hash
600
-		$result = User::checkPassword("", '');
601
-		$this->assertEquals(false,$result);
599
+        //test with empty password and empty hash
600
+        $result = User::checkPassword("", '');
601
+        $this->assertEquals(false,$result);
602 602
 
603 603
 
604
-		//test with valid hash and empty password
605
-		$result = User::checkPassword("", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
606
-		$this->assertEquals(false,$result);
604
+        //test with valid hash and empty password
605
+        $result = User::checkPassword("", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
606
+        $this->assertEquals(false,$result);
607 607
 
608 608
 
609
-		//test with valid password and invalid hash
610
-		$result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
611
-		$this->assertEquals(false,$result);
609
+        //test with valid password and invalid hash
610
+        $result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
611
+        $this->assertEquals(false,$result);
612 612
 
613 613
 
614
-		//test with valid password and valid hash
615
-		$result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
616
-		$this->assertEquals(true,$result);
614
+        //test with valid password and valid hash
615
+        $result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
616
+        $this->assertEquals(true,$result);
617 617
 
618
-	}
618
+    }
619 619
 
620 620
 
621
-	public function testcheckPasswordMD5()
622
-	{
621
+    public function testcheckPasswordMD5()
622
+    {
623 623
 
624
-		//test with empty password and empty hash
625
-		$result = User::checkPasswordMD5(md5(""), '');
626
-		$this->assertEquals(false,$result);
624
+        //test with empty password and empty hash
625
+        $result = User::checkPasswordMD5(md5(""), '');
626
+        $this->assertEquals(false,$result);
627 627
 
628 628
 
629
-		//test with valid hash and empty password
630
-		$result = User::checkPasswordMD5(md5(""), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
631
-		$this->assertEquals(false,$result);
629
+        //test with valid hash and empty password
630
+        $result = User::checkPasswordMD5(md5(""), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
631
+        $this->assertEquals(false,$result);
632 632
 
633 633
 
634
-		//test with valid password and invalid hash
635
-		$result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
636
-		$this->assertEquals(false,$result);
634
+        //test with valid password and invalid hash
635
+        $result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
636
+        $this->assertEquals(false,$result);
637 637
 
638 638
 
639
-		//test with valid password and valid hash
640
-		$result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
641
-		$this->assertEquals(true,$result);
639
+        //test with valid password and valid hash
640
+        $result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
641
+        $this->assertEquals(true,$result);
642 642
 
643
-	}
643
+    }
644 644
 
645 645
 
646
-	public function testis_authenticated()
647
-	{
646
+    public function testis_authenticated()
647
+    {
648 648
 
649
-		$user = new User();
649
+        $user = new User();
650 650
 
651
-		//test without setting name
652
-		$this->assertEquals(false, $user->is_authenticated());
651
+        //test without setting name
652
+        $this->assertEquals(false, $user->is_authenticated());
653 653
 
654
-		//test with name set
655
-		$user->authenticated = true;
656
-		$this->assertEquals(true,$user->is_authenticated());
654
+        //test with name set
655
+        $user->authenticated = true;
656
+        $this->assertEquals(true,$user->is_authenticated());
657 657
 
658
-	}
658
+    }
659 659
 
660
-	public function testfill_in_additional_list_fields()
661
-	{
660
+    public function testfill_in_additional_list_fields()
661
+    {
662 662
 
663
-		$user = new User();
663
+        $user = new User();
664 664
 
665
-		$user->retrieve(1);
665
+        $user->retrieve(1);
666 666
 
667
-		$user->fill_in_additional_list_fields();
667
+        $user->fill_in_additional_list_fields();
668 668
 
669
-		$this->assertEquals("Administrator",$user->full_name);
669
+        $this->assertEquals("Administrator",$user->full_name);
670 670
 
671
-	}
671
+    }
672 672
 
673
-	public function testfill_in_additional_detail_fields()
674
-	{
673
+    public function testfill_in_additional_detail_fields()
674
+    {
675 675
 
676
-		$user = new User();
676
+        $user = new User();
677 677
 
678
-		$user->retrieve(1);
678
+        $user->retrieve(1);
679 679
 
680
-		$user->fill_in_additional_detail_fields();
680
+        $user->fill_in_additional_detail_fields();
681 681
 
682
-		$this->assertEquals("Administrator",$user->full_name);
682
+        $this->assertEquals("Administrator",$user->full_name);
683 683
 
684
-	}
684
+    }
685 685
 
686
-	public function testretrieve_user_id()
687
-	{
688
-		$user = new User();
686
+    public function testretrieve_user_id()
687
+    {
688
+        $user = new User();
689 689
 
690
-		$result = $user->retrieve_user_id("admin");
691
-		$this->assertEquals(1, $result);
692
-	}
690
+        $result = $user->retrieve_user_id("admin");
691
+        $this->assertEquals(1, $result);
692
+    }
693 693
 
694 694
 
695
-	public function testverify_data()
696
-	{
695
+    public function testverify_data()
696
+    {
697 697
 
698
-		global $mod_strings;
698
+        global $mod_strings;
699 699
 
700
-		$mod_strings['ERR_EMAIL_NO_OPTS'] = "";
700
+        $mod_strings['ERR_EMAIL_NO_OPTS'] = "";
701 701
 
702
-		$user = new User();
702
+        $user = new User();
703 703
 
704
-		$user->retrieve(1);
704
+        $user->retrieve(1);
705 705
 
706
-		//test with default/true
707
-		$result = $user->verify_data();
708
-		$this->assertEquals(true, $result);
706
+        //test with default/true
707
+        $result = $user->verify_data();
708
+        $this->assertEquals(true, $result);
709 709
 
710 710
 
711
-		//test with false
712
-		$result = $user->verify_data(false);
713
-		$this->assertEquals(false, $result);
711
+        //test with false
712
+        $result = $user->verify_data(false);
713
+        $this->assertEquals(false, $result);
714 714
 
715
-	}
715
+    }
716 716
 
717
-	public function testget_list_view_data()
718
-	{
719
-		global $mod_strings;
720
-		$mod_strings['LBL_CHECKMARK'] = "";
717
+    public function testget_list_view_data()
718
+    {
719
+        global $mod_strings;
720
+        $mod_strings['LBL_CHECKMARK'] = "";
721 721
 
722
-		$user = new User();
722
+        $user = new User();
723 723
 
724
-		$user->retrieve(1);
724
+        $user->retrieve(1);
725 725
 
726
-		$result = $user->get_list_view_data();
727
-		$this->assertTrue(is_array($result));
726
+        $result = $user->get_list_view_data();
727
+        $this->assertTrue(is_array($result));
728 728
 
729
-	}
729
+    }
730 730
 
731
-	public function testlist_view_parse_additional_sections()
732
-	{
731
+    public function testlist_view_parse_additional_sections()
732
+    {
733 733
 
734
-		$user = new User();
734
+        $user = new User();
735 735
 
736
-		$list_form = array();
737
-		$result = $user->list_view_parse_additional_sections($list_form);
738
-		$this->assertSame($list_form, $result);
736
+        $list_form = array();
737
+        $result = $user->list_view_parse_additional_sections($list_form);
738
+        $this->assertSame($list_form, $result);
739 739
 
740
-	}
740
+    }
741 741
 
742 742
     public function testGetAllUsersAndGetActiveUsers()
743 743
     {
744 744
 
745
-    	$all_users = User::getAllUsers();
746
-    	$this->assertTrue(is_array($all_users));
745
+        $all_users = User::getAllUsers();
746
+        $this->assertTrue(is_array($all_users));
747 747
 
748
-    	$active_users = User::getActiveUsers();
749
-    	$this->assertTrue(is_array($active_users));
748
+        $active_users = User::getActiveUsers();
749
+        $this->assertTrue(is_array($active_users));
750 750
 
751
-    	$this->assertGreaterThanOrEqual(count($active_users), count($all_users));
751
+        $this->assertGreaterThanOrEqual(count($active_users), count($all_users));
752 752
     }
753 753
 
754 754
 
755
-	public function testcreate_export_query() {
755
+    public function testcreate_export_query() {
756 756
 
757
-		$user = new User();
757
+        $user = new User();
758 758
 
759
-    	//test with empty string params
760
-    	$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 AND users.is_admin=0 ORDER BY users.user_name";
761
-    	$actual = $user->create_export_query('','');
762
-    	$this->assertSame($expected,$actual);
759
+        //test with empty string params
760
+        $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 AND users.is_admin=0 ORDER BY users.user_name";
761
+        $actual = $user->create_export_query('','');
762
+        $this->assertSame($expected,$actual);
763 763
 
764 764
 
765
-    	//test with valid string params
766
-    	$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE user_name=\"\" AND  users.deleted = 0 AND users.is_admin=0 ORDER BY id";
767
-    	$actual = $user->create_export_query('id','user_name=""');
768
-    	$this->assertSame($expected,$actual);
765
+        //test with valid string params
766
+        $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE user_name=\"\" AND  users.deleted = 0 AND users.is_admin=0 ORDER BY id";
767
+        $actual = $user->create_export_query('id','user_name=""');
768
+        $this->assertSame($expected,$actual);
769 769
 
770
-	}
770
+    }
771 771
 
772 772
 
773
-	public function testget_meetings() {
773
+    public function testget_meetings() {
774 774
 
775
-		$user = new User();
775
+        $user = new User();
776 776
 
777
-		$result = $user->get_meetings();
778
-		$this->assertTrue(is_array($result));
777
+        $result = $user->get_meetings();
778
+        $this->assertTrue(is_array($result));
779 779
 
780
-	}
780
+    }
781 781
 
782
-	public function testget_calls() {
782
+    public function testget_calls() {
783 783
 
784
-		$user = new User();
784
+        $user = new User();
785 785
 
786
-		//$result = $user->get_calls();
787
-		//$this->assertTrue(is_array($result));
786
+        //$result = $user->get_calls();
787
+        //$this->assertTrue(is_array($result));
788 788
 
789
-		$this->markTestIncomplete('Error:Only variables should be passed by reference');
790
-	}
789
+        $this->markTestIncomplete('Error:Only variables should be passed by reference');
790
+    }
791 791
 
792 792
 
793
-	public function testdisplayEmailCounts() {
793
+    public function testdisplayEmailCounts() {
794 794
 
795
-		//unset and reconnect Db to resolve mysqli fetch exeception
796
-		global $db;
797
-		unset ($db->database);
798
-		$db->checkConnection();
795
+        //unset and reconnect Db to resolve mysqli fetch exeception
796
+        global $db;
797
+        unset ($db->database);
798
+        $db->checkConnection();
799 799
 
800 800
 
801
-		$user = new User();
801
+        $user = new User();
802 802
 
803
-		$expected = '<script type="text/javascript" language="Javascript">var welcome = document.getElementById("welcome");var welcomeContent = welcome.innerHTML;welcome.innerHTML = welcomeContent + "&nbsp;&nbsp;&nbsp;&nbsp;<a href=index.php?module=Emails&action=ListViewGroup>Group Inbox: (0 New)</a>";</script>';
803
+        $expected = '<script type="text/javascript" language="Javascript">var welcome = document.getElementById("welcome");var welcomeContent = welcome.innerHTML;welcome.innerHTML = welcomeContent + "&nbsp;&nbsp;&nbsp;&nbsp;<a href=index.php?module=Emails&action=ListViewGroup>Group Inbox: (0 New)</a>";</script>';
804 804
 
805
-		//cpature the screen output and compare with exected values
805
+        //cpature the screen output and compare with exected values
806 806
 
807
-		ob_start();
807
+        ob_start();
808 808
 
809
-		$user->displayEmailCounts();
809
+        $user->displayEmailCounts();
810 810
 
811
-		$renderedContent = ob_get_contents();
812
-		ob_end_clean();
811
+        $renderedContent = ob_get_contents();
812
+        ob_end_clean();
813 813
 
814
-		$this->assertSame($expected,$renderedContent);
814
+        $this->assertSame($expected,$renderedContent);
815 815
 
816
-	}
816
+    }
817 817
 
818 818
 
819
-	public function testgetSystemDefaultNameAndEmail()
820
-	{
819
+    public function testgetSystemDefaultNameAndEmail()
820
+    {
821 821
 
822
-		$user = new User();
822
+        $user = new User();
823 823
 
824
-		$expected = array( 'email' => '[email protected]', 'name' => 'SuiteCRM');
825
-		$actual = $user->getSystemDefaultNameAndEmail();
826
-		$this->assertSame($expected,$actual);
824
+        $expected = array( 'email' => '[email protected]', 'name' => 'SuiteCRM');
825
+        $actual = $user->getSystemDefaultNameAndEmail();
826
+        $this->assertSame($expected,$actual);
827 827
 
828
-	}
828
+    }
829 829
 
830 830
 
831
-	public function testsetDefaultsInConfig()
832
-	{
833
-		$user = new User();
831
+    public function testsetDefaultsInConfig()
832
+    {
833
+        $user = new User();
834 834
 
835
-		$result = $user->setDefaultsInConfig();
835
+        $result = $user->setDefaultsInConfig();
836 836
 
837
-		$this->assertTrue(is_array($result));
838
-		$this->assertEquals('sugar', $result['email_default_client']);
839
-		$this->assertEquals('html', $result['email_default_editor']);
837
+        $this->assertTrue(is_array($result));
838
+        $this->assertEquals('sugar', $result['email_default_client']);
839
+        $this->assertEquals('html', $result['email_default_editor']);
840 840
 
841
-	}
841
+    }
842 842
 
843 843
 
844
-	public function testgetEmailLink2()
845
-	{
846
-		$user = new User();
844
+    public function testgetEmailLink2()
845
+    {
846
+        $user = new User();
847 847
 
848
-		$user->retrieve(1);
848
+        $user->retrieve(1);
849 849
 
850 850
 
851
-		//test with accounts module
852
-		$account = new Account();
853
-		$account->name = "test";
851
+        //test with accounts module
852
+        $account = new Account();
853
+        $account->name = "test";
854 854
 
855
-		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \[email protected]\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
856
-		$actual = $user->getEmailLink2("[email protected]", $account);
857
-		$this->assertSame($expected,$actual);
855
+        $expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \[email protected]\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
856
+        $actual = $user->getEmailLink2("[email protected]", $account);
857
+        $this->assertSame($expected,$actual);
858 858
 
859 859
 
860
-		//test with contacts module
861
-		$contact = new Contact();
862
-		$contact->name = "test";
860
+        //test with contacts module
861
+        $contact = new Contact();
862
+        $contact->name = "test";
863 863
 
864
-		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \[email protected]\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
865
-		$actual = $user->getEmailLink2("[email protected]", $contact);
866
-		$this->assertSame($expected,$actual);
864
+        $expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \[email protected]\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
865
+        $actual = $user->getEmailLink2("[email protected]", $contact);
866
+        $this->assertSame($expected,$actual);
867 867
 
868
-	}
868
+    }
869 869
 
870 870
 
871
-	public function testgetEmailLink()
872
-	{
871
+    public function testgetEmailLink()
872
+    {
873 873
 
874
-		$user = new User();
874
+        $user = new User();
875 875
 
876
-		$user->retrieve(1);
876
+        $user->retrieve(1);
877 877
 
878 878
 
879
-		//test with accounts module
880
-		$account = new Account();
881
-		$account->name = "test";
879
+        //test with accounts module
880
+        $account = new Account();
881
+        $account->name = "test";
882 882
 
883
-		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \u003Ctest\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
884
-		$actual = $user->getEmailLink("name", $account);
885
-		$this->assertSame($expected,$actual);
883
+        $expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \u003Ctest\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
884
+        $actual = $user->getEmailLink("name", $account);
885
+        $this->assertSame($expected,$actual);
886 886
 
887 887
 
888
-		//test with contacts module
889
-		$contact = new Contact();
890
-		$contact->name = "test";
888
+        //test with contacts module
889
+        $contact = new Contact();
890
+        $contact->name = "test";
891 891
 
892
-		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \u003Ctest\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
893
-		$actual = $user->getEmailLink("name", $contact);
894
-		$this->assertSame($expected,$actual);
892
+        $expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \u003Ctest\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
893
+        $actual = $user->getEmailLink("name", $contact);
894
+        $this->assertSame($expected,$actual);
895 895
 
896
-	}
896
+    }
897 897
 
898
-	public function testgetLocaleFormatDesc()
899
-	{
900
-		$user = new User();
898
+    public function testgetLocaleFormatDesc()
899
+    {
900
+        $user = new User();
901 901
 
902
-		$result = $user->getLocaleFormatDesc();
903
-		$this->assertTrue(isset($result));
904
-		$this->assertGreaterThan(0,strlen($result));
902
+        $result = $user->getLocaleFormatDesc();
903
+        $this->assertTrue(isset($result));
904
+        $this->assertGreaterThan(0,strlen($result));
905 905
 
906
-	}
906
+    }
907 907
 
908 908
     public function testisAdmin()
909 909
     {
910
-    	$user = new User();
910
+        $user = new User();
911 911
 
912
-    	//test without setting attribute
913
-    	$this->assertEquals(false, $user->isAdmin());
912
+        //test without setting attribute
913
+        $this->assertEquals(false, $user->isAdmin());
914 914
 
915
-    	//test with attribute set
916
-    	$user->is_admin = 1;
917
-    	$this->assertEquals(true, $user->isAdmin());
915
+        //test with attribute set
916
+        $user->is_admin = 1;
917
+        $this->assertEquals(true, $user->isAdmin());
918 918
 
919 919
     }
920 920
 
921 921
     public function testisDeveloperForAnyModule()
922 922
     {
923
-    	$user = new User();
923
+        $user = new User();
924 924
 
925
-    	//test without setting is_admin
926
-    	$this->assertEquals(false, $user->isDeveloperForAnyModule());
925
+        //test without setting is_admin
926
+        $this->assertEquals(false, $user->isDeveloperForAnyModule());
927 927
 
928 928
 
929
-    	//test with id set
930
-    	$user->id = 1;
931
-    	$this->assertEquals(false, $user->isDeveloperForAnyModule());
929
+        //test with id set
930
+        $user->id = 1;
931
+        $this->assertEquals(false, $user->isDeveloperForAnyModule());
932 932
 
933 933
 
934
-    	//test with id and is_admin set
935
-    	$user->is_admin = 1;
936
-    	$this->assertEquals(true, $user->isDeveloperForAnyModule());
934
+        //test with id and is_admin set
935
+        $user->is_admin = 1;
936
+        $this->assertEquals(true, $user->isDeveloperForAnyModule());
937 937
 
938 938
     }
939 939
 
940 940
     public function testgetDeveloperModules()
941 941
     {
942
-    	//unset and reconnect Db to resolve mysqli fetch exeception
943
-    	global $db;
944
-    	unset ($db->database);
945
-    	$db->checkConnection();
942
+        //unset and reconnect Db to resolve mysqli fetch exeception
943
+        global $db;
944
+        unset ($db->database);
945
+        $db->checkConnection();
946 946
 
947
-    	$user = new User();
947
+        $user = new User();
948 948
 
949
-    	$user->retrieve(1);
949
+        $user->retrieve(1);
950 950
 
951
-    	$result = $user->getDeveloperModules();
952
-    	$this->assertTrue(is_array($result));
951
+        $result = $user->getDeveloperModules();
952
+        $this->assertTrue(is_array($result));
953 953
 
954 954
     }
955 955
 
956 956
     public function testisDeveloperForModule()
957 957
     {
958
-    	global $db;
959
-    	unset ($db->database);
960
-    	$db->checkConnection();
958
+        global $db;
959
+        unset ($db->database);
960
+        $db->checkConnection();
961 961
 
962
-    	$user = new User();
962
+        $user = new User();
963 963
 
964 964
 
965
-    	//test without setting is_admin
966
-    	$this->assertEquals(false, $user->isDeveloperForModule("Accounts"));
965
+        //test without setting is_admin
966
+        $this->assertEquals(false, $user->isDeveloperForModule("Accounts"));
967 967
 
968 968
 
969
-    	//test with id set
970
-    	$user->id = 1;
971
-    	$this->assertEquals(false, $user->isDeveloperForModule("Accounts"));
969
+        //test with id set
970
+        $user->id = 1;
971
+        $this->assertEquals(false, $user->isDeveloperForModule("Accounts"));
972 972
 
973 973
 
974
-    	//test with id and is_admin set
975
-    	$user->is_admin = 1;
976
-    	$this->assertEquals(true, $user->isDeveloperForModule("Accounts"));
974
+        //test with id and is_admin set
975
+        $user->is_admin = 1;
976
+        $this->assertEquals(true, $user->isDeveloperForModule("Accounts"));
977 977
 
978 978
 
979 979
     }
@@ -981,59 +981,59 @@  discard block
 block discarded – undo
981 981
     public function testgetAdminModules()
982 982
     {
983 983
         //unset and reconnect Db to resolve mysqli fetch exeception
984
-    	global $db;
985
-    	unset ($db->database);
986
-    	$db->checkConnection();
984
+        global $db;
985
+        unset ($db->database);
986
+        $db->checkConnection();
987 987
 
988
-    	$user = new User();
988
+        $user = new User();
989 989
 
990
-    	$user->retrieve(1);
990
+        $user->retrieve(1);
991 991
 
992
-    	$result = $user->getAdminModules();
993
-    	$this->assertTrue(is_array($result));
992
+        $result = $user->getAdminModules();
993
+        $this->assertTrue(is_array($result));
994 994
 
995 995
     }
996 996
 
997 997
     public function testisAdminForModule()
998 998
     {
999
-    	global $db;
1000
-    	unset ($db->database);
1001
-    	$db->checkConnection();
999
+        global $db;
1000
+        unset ($db->database);
1001
+        $db->checkConnection();
1002 1002
 
1003
-    	$user = new User();
1003
+        $user = new User();
1004 1004
 
1005 1005
 
1006
-    	//test without setting is_admin
1007
-    	$this->assertEquals(false, $user->isAdminForModule("Accounts"));
1006
+        //test without setting is_admin
1007
+        $this->assertEquals(false, $user->isAdminForModule("Accounts"));
1008 1008
 
1009 1009
 
1010
-    	//test with id set
1011
-    	$user->id = 1;
1012
-    	$this->assertEquals(false, $user->isAdminForModule("Accounts"));
1010
+        //test with id set
1011
+        $user->id = 1;
1012
+        $this->assertEquals(false, $user->isAdminForModule("Accounts"));
1013 1013
 
1014 1014
 
1015
-    	//test with id and is_admin set
1016
-    	$user->is_admin = 1;
1017
-    	$this->assertEquals(true, $user->isAdminForModule("Accounts"));
1015
+        //test with id and is_admin set
1016
+        $user->is_admin = 1;
1017
+        $this->assertEquals(true, $user->isAdminForModule("Accounts"));
1018 1018
 
1019 1019
 
1020 1020
     }
1021 1021
 
1022
-	public function testshowLastNameFirst()
1023
-	{
1024
-		$user = new User();
1022
+    public function testshowLastNameFirst()
1023
+    {
1024
+        $user = new User();
1025 1025
 
1026
-		$result = $user->showLastNameFirst();
1027
-		$this->assertEquals(false, $result);
1026
+        $result = $user->showLastNameFirst();
1027
+        $this->assertEquals(false, $result);
1028 1028
 
1029
-	}
1029
+    }
1030 1030
 
1031 1031
     /**
1032 1032
      * @todo: NEEDS FIXING!
1033 1033
      */
1034
-   public function testcreate_new_list_query()
1035
-   {
1036
-       /*
1034
+    public function testcreate_new_list_query()
1035
+    {
1036
+        /*
1037 1037
 	   	$user = new User();
1038 1038
 
1039 1039
 	   	//test with empty string params
@@ -1048,31 +1048,31 @@  discard block
 block discarded – undo
1048 1048
 	   	$actual = $user->create_new_list_query('id','user_name=""');
1049 1049
 	   	$this->assertSame($expected,$actual);
1050 1050
        */
1051
-       $this->assertTrue(true, "NEEDS FIXING!");
1052
-   }
1051
+        $this->assertTrue(true, "NEEDS FIXING!");
1052
+    }
1053 1053
 
1054 1054
 
1055 1055
     public function testget_first_day_of_week()
1056 1056
     {
1057
-    	$user = new User();
1057
+        $user = new User();
1058 1058
 
1059
-    	$result = $user->get_first_day_of_week();
1060
-    	$this->assertTrue(is_numeric($result));
1059
+        $result = $user->get_first_day_of_week();
1060
+        $this->assertTrue(is_numeric($result));
1061 1061
 
1062 1062
     }
1063 1063
 
1064 1064
 
1065 1065
     public function testgeneratePassword()
1066 1066
     {
1067
-    	//generate apsswords and verify they are not same
1067
+        //generate apsswords and verify they are not same
1068 1068
 
1069
-    	$password1 = User::generatePassword();
1070
-    	$this->assertGreaterThan(0,strlen($password1));
1069
+        $password1 = User::generatePassword();
1070
+        $this->assertGreaterThan(0,strlen($password1));
1071 1071
 
1072
-    	$password2 = User::generatePassword();
1073
-    	$this->assertGreaterThan(0,strlen($password2));
1072
+        $password2 = User::generatePassword();
1073
+        $this->assertGreaterThan(0,strlen($password2));
1074 1074
 
1075
-    	$this->assertNotEquals($password1, $password2);
1075
+        $this->assertNotEquals($password1, $password2);
1076 1076
 
1077 1077
     }
1078 1078
 
@@ -1080,50 +1080,50 @@  discard block
 block discarded – undo
1080 1080
     public function testsendEmailForPassword()
1081 1081
     {
1082 1082
 
1083
-    	$user = new User();
1083
+        $user = new User();
1084 1084
 
1085
-    	$result = $user->sendEmailForPassword("1");
1085
+        $result = $user->sendEmailForPassword("1");
1086 1086
 
1087
-    	//expected result is a array with template not found message.
1088
-    	$this->assertTrue(is_array($result));
1087
+        //expected result is a array with template not found message.
1088
+        $this->assertTrue(is_array($result));
1089 1089
 
1090 1090
     }
1091 1091
 
1092 1092
 
1093 1093
     public function testafterImportSave()
1094 1094
     {
1095
-    	error_reporting(E_ALL);
1095
+        error_reporting(E_ALL);
1096 1096
 
1097
-    	$user = new User();
1097
+        $user = new User();
1098 1098
 
1099
-    	//execute the method and test if it works and does not throws an exception.
1100
-    	try {
1101
-    		$result = $user->afterImportSave();
1102
-    		$this->assertTrue(true);
1103
-    	}
1104
-    	catch (Exception $e) {
1105
-    		$this->assertStringStartsWith('Cannot modify header information', $e->getMessage());
1106
-    	}
1099
+        //execute the method and test if it works and does not throws an exception.
1100
+        try {
1101
+            $result = $user->afterImportSave();
1102
+            $this->assertTrue(true);
1103
+        }
1104
+        catch (Exception $e) {
1105
+            $this->assertStringStartsWith('Cannot modify header information', $e->getMessage());
1106
+        }
1107 1107
 
1108 1108
     }
1109 1109
 
1110 1110
 
1111 1111
     public function testisPrimaryEmail()
1112 1112
     {
1113
-    	$user = new User();
1113
+        $user = new User();
1114 1114
 
1115
-    	//test without user email
1116
-    	$this->assertEquals(false, $user->isPrimaryEmail("[email protected]"));
1115
+        //test without user email
1116
+        $this->assertEquals(false, $user->isPrimaryEmail("[email protected]"));
1117 1117
 
1118 1118
 
1119
-    	//test with non matching user email
1120
-    	$user->email1 = "[email protected]";
1121
-    	$this->assertEquals(false, $user->isPrimaryEmail("[email protected]"));
1119
+        //test with non matching user email
1120
+        $user->email1 = "[email protected]";
1121
+        $this->assertEquals(false, $user->isPrimaryEmail("[email protected]"));
1122 1122
 
1123 1123
 
1124
-    	//test with matching user email
1125
-    	$user->email1 = "[email protected]";
1126
-    	$this->assertEquals(true, $user->isPrimaryEmail("[email protected]"));
1124
+        //test with matching user email
1125
+        $user->email1 = "[email protected]";
1126
+        $this->assertEquals(true, $user->isPrimaryEmail("[email protected]"));
1127 1127
 
1128 1128
     }
1129 1129
 
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
 		//execute the contructor and check for the Object type and  attributes
10 10
 		$user = new User();
11 11
 
12
-		$this->assertInstanceOf('User',$user);
13
-		$this->assertInstanceOf('Person',$user);
14
-		$this->assertInstanceOf('SugarBean',$user);
12
+		$this->assertInstanceOf('User', $user);
13
+		$this->assertInstanceOf('Person', $user);
14
+		$this->assertInstanceOf('SugarBean', $user);
15 15
 
16 16
 		$this->assertAttributeEquals('Users', 'module_dir', $user);
17 17
 		$this->assertAttributeEquals('User', 'object_name', $user);
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     	$result = $user->getSystemUser();
38 38
 
39
-    	$this->assertInstanceOf('User',$result);
39
+    	$this->assertInstanceOf('User', $result);
40 40
     	$this->assertEquals(1, $result->id);
41 41
 
42 42
     }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		$user->retrieve(1);
67 67
 
68 68
 		$result = $user->getSignature(1);
69
-		$this->assertEquals(false,$result);
69
+		$this->assertEquals(false, $result);
70 70
 
71 71
 	}
72 72
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
 		//test with defaultDisplay true
118 118
 		$expected = "<input class='button' onclick='javascript:open_email_signature_form(\"\", \"1\");' value='' type='button'>&nbsp;<span name=\"edit_sig\" id=\"edit_sig\" style=\"visibility:inherit;\"><input class=\"button\" onclick=\"javascript:open_email_signature_form(document.getElementById('signature_id', '').value)\" value=\"\" type=\"button\" tabindex=\"392\">&nbsp;\n					</span>";
119
-		$actual = $user->getSignatureButtons('',true);
119
+		$actual = $user->getSignatureButtons('', true);
120 120
 		$this->assertSame($expected, $actual);
121 121
 
122 122
 	}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$user->retrieve(2);
131 131
 
132 132
 		$result = $user->hasPersonalEmail();
133
-		$this->assertEquals(false,$result);
133
+		$this->assertEquals(false, $result);
134 134
 
135 135
 	}
136 136
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	}
286 286
 
287 287
 
288
-    public function testGetETagSeedAndIncrementETag(){
288
+    public function testGetETagSeedAndIncrementETag() {
289 289
 
290 290
     	//unset and reconnect Db to resolve mysqli fetch exeception
291 291
     	global $db;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
     	//execute getETagSeed method, get Etag value
300 300
     	$ETagInitial = $user->getETagSeed('test');
301
-    	$this->assertGreaterThanOrEqual(0,$ETagInitial);
301
+    	$this->assertGreaterThanOrEqual(0, $ETagInitial);
302 302
 
303 303
 
304 304
     	//execute incrementETag to increment
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
     	$user = new User();
327 327
 
328 328
     	//test without setting name
329
-    	$this->assertEquals(Null,$user->get_summary_text());
329
+    	$this->assertEquals(Null, $user->get_summary_text());
330 330
 
331 331
     	//test with name set
332 332
     	$user->name = "test";
333
-    	$this->assertEquals('test',$user->get_summary_text());
333
+    	$this->assertEquals('test', $user->get_summary_text());
334 334
 
335 335
 	}
336 336
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 
378 378
 		$user->user_name  = "test";
379 379
 
380
-		$user->first_name  = "firstn";
380
+		$user->first_name = "firstn";
381 381
 		$user->last_name  = "lastn";
382 382
 
383 383
 		$user->email1 = "[email protected]";
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
 
429 429
 		//change username and delete the user to avoid picking it up by password in future
430
-		$user->user_name  = "test_deleted";
430
+		$user->user_name = "test_deleted";
431 431
 		$user->save();
432 432
 		$user->mark_deleted($user->id);
433 433
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 		//set user password and then retrieve user by created password
475 475
 		$user->setNewPassword("test");
476 476
 
477
-		$result = User::findUserPassword("test",md5("test"));
477
+		$result = User::findUserPassword("test", md5("test"));
478 478
 
479 479
 		$this->assertTrue(isset($result['id']));
480 480
 		$this->assertEquals($id, $result['id']);
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 
491 491
 		//test with invalid password
492 492
 		$result = $user->authenticate_user(md5("pass"));
493
-		$this->assertEquals(false ,$result);
493
+		$this->assertEquals(false, $result);
494 494
 
495 495
 		//test with invalid password
496 496
 		$result = $user->authenticate_user(md5("test"));
497
-		$this->assertEquals(true ,$result);
497
+		$this->assertEquals(true, $result);
498 498
 
499 499
 	}
500 500
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
 
525 525
 		//find the user by new password
526
-		$result = User::findUserPassword("test",md5("testpass"));
526
+		$result = User::findUserPassword("test", md5("testpass"));
527 527
 
528 528
 		$this->assertTrue(isset($result['id']));
529 529
 		$this->assertEquals($id, $result['id']);
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 
537 537
 		$user->retrieve($id);
538 538
 
539
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
539
+		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]");
540 540
 
541 541
 		$actual = $user->getPreferredEmail();
542 542
 
543
-		$this->assertSame($actual,$expected);
543
+		$this->assertSame($actual, $expected);
544 544
 
545 545
 	}
546 546
 
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 
551 551
 		$user->retrieve($id);
552 552
 
553
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
553
+		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]");
554 554
 
555 555
 		$actual = $user->getUsersNameAndEmail();
556 556
 
557
-		$this->assertEquals($actual,$expected);
557
+		$this->assertEquals($actual, $expected);
558 558
 	}
559 559
 
560 560
 
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	{
563 563
 		$user = new User();
564 564
 
565
-		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]" );
565
+		$expected = array("name"=>"firstn lastn", "email"=>"[email protected]");
566 566
 
567 567
 		$actual = $user->getEmailInfo($id);
568 568
 
569
-		$this->assertEquals($actual,$expected);
569
+		$this->assertEquals($actual, $expected);
570 570
 	}
571 571
 
572 572
 
@@ -576,17 +576,17 @@  discard block
 block discarded – undo
576 576
 
577 577
 		$result = $user->encrypt_password("test");
578 578
 		$this->assertTrue(isset($result));
579
-		$this->assertGreaterThan(0,strlen($result));
579
+		$this->assertGreaterThan(0, strlen($result));
580 580
 
581 581
 	}
582 582
 
583 583
 	public function testgetPasswordHash()
584 584
 	{
585 585
 
586
-		$result= User::getPasswordHash("test");
586
+		$result = User::getPasswordHash("test");
587 587
 
588 588
 		$this->assertTrue(isset($result));
589
-		$this->assertGreaterThan(0,strlen($result));
589
+		$this->assertGreaterThan(0, strlen($result));
590 590
 
591 591
 		$this->markTestIncomplete('Error: crypt(): No salt parameter was specified. You must use a randomly generated salt and a strong hash function to produce a secure hash.');
592 592
 
@@ -598,22 +598,22 @@  discard block
 block discarded – undo
598 598
 
599 599
 		//test with empty password and empty hash
600 600
 		$result = User::checkPassword("", '');
601
-		$this->assertEquals(false,$result);
601
+		$this->assertEquals(false, $result);
602 602
 
603 603
 
604 604
 		//test with valid hash and empty password
605 605
 		$result = User::checkPassword("", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
606
-		$this->assertEquals(false,$result);
606
+		$this->assertEquals(false, $result);
607 607
 
608 608
 
609 609
 		//test with valid password and invalid hash
610 610
 		$result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
611
-		$this->assertEquals(false,$result);
611
+		$this->assertEquals(false, $result);
612 612
 
613 613
 
614 614
 		//test with valid password and valid hash
615 615
 		$result = User::checkPassword("test", '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
616
-		$this->assertEquals(true,$result);
616
+		$this->assertEquals(true, $result);
617 617
 
618 618
 	}
619 619
 
@@ -623,22 +623,22 @@  discard block
 block discarded – undo
623 623
 
624 624
 		//test with empty password and empty hash
625 625
 		$result = User::checkPasswordMD5(md5(""), '');
626
-		$this->assertEquals(false,$result);
626
+		$this->assertEquals(false, $result);
627 627
 
628 628
 
629 629
 		//test with valid hash and empty password
630 630
 		$result = User::checkPasswordMD5(md5(""), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
631
-		$this->assertEquals(false,$result);
631
+		$this->assertEquals(false, $result);
632 632
 
633 633
 
634 634
 		//test with valid password and invalid hash
635 635
 		$result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la2');
636
-		$this->assertEquals(false,$result);
636
+		$this->assertEquals(false, $result);
637 637
 
638 638
 
639 639
 		//test with valid password and valid hash
640 640
 		$result = User::checkPasswordMD5(md5("test"), '$1$Gt0.XI4.$tVVSXgE36sfsVMBNo/9la1');
641
-		$this->assertEquals(true,$result);
641
+		$this->assertEquals(true, $result);
642 642
 
643 643
 	}
644 644
 
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 
654 654
 		//test with name set
655 655
 		$user->authenticated = true;
656
-		$this->assertEquals(true,$user->is_authenticated());
656
+		$this->assertEquals(true, $user->is_authenticated());
657 657
 
658 658
 	}
659 659
 
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 
667 667
 		$user->fill_in_additional_list_fields();
668 668
 
669
-		$this->assertEquals("Administrator",$user->full_name);
669
+		$this->assertEquals("Administrator", $user->full_name);
670 670
 
671 671
 	}
672 672
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
 		$user->fill_in_additional_detail_fields();
681 681
 
682
-		$this->assertEquals("Administrator",$user->full_name);
682
+		$this->assertEquals("Administrator", $user->full_name);
683 683
 
684 684
 	}
685 685
 
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 
759 759
     	//test with empty string params
760 760
     	$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 AND users.is_admin=0 ORDER BY users.user_name";
761
-    	$actual = $user->create_export_query('','');
762
-    	$this->assertSame($expected,$actual);
761
+    	$actual = $user->create_export_query('', '');
762
+    	$this->assertSame($expected, $actual);
763 763
 
764 764
 
765 765
     	//test with valid string params
766 766
     	$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE user_name=\"\" AND  users.deleted = 0 AND users.is_admin=0 ORDER BY id";
767
-    	$actual = $user->create_export_query('id','user_name=""');
768
-    	$this->assertSame($expected,$actual);
767
+    	$actual = $user->create_export_query('id', 'user_name=""');
768
+    	$this->assertSame($expected, $actual);
769 769
 
770 770
 	}
771 771
 
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		$renderedContent = ob_get_contents();
812 812
 		ob_end_clean();
813 813
 
814
-		$this->assertSame($expected,$renderedContent);
814
+		$this->assertSame($expected, $renderedContent);
815 815
 
816 816
 	}
817 817
 
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
 
822 822
 		$user = new User();
823 823
 
824
-		$expected = array( 'email' => '[email protected]', 'name' => 'SuiteCRM');
824
+		$expected = array('email' => '[email protected]', 'name' => 'SuiteCRM');
825 825
 		$actual = $user->getSystemDefaultNameAndEmail();
826
-		$this->assertSame($expected,$actual);
826
+		$this->assertSame($expected, $actual);
827 827
 
828 828
 	}
829 829
 
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 
855 855
 		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \[email protected]\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
856 856
 		$actual = $user->getEmailLink2("[email protected]", $account);
857
-		$this->assertSame($expected,$actual);
857
+		$this->assertSame($expected, $actual);
858 858
 
859 859
 
860 860
 		//test with contacts module
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
 		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Babc%40email.com%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \[email protected]\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
865 865
 		$actual = $user->getEmailLink2("[email protected]", $contact);
866
-		$this->assertSame($expected,$actual);
866
+		$this->assertSame($expected, $actual);
867 867
 
868 868
 	}
869 869
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 
883 883
 		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Accounts\u0026parent_id=\u0026parent_name=test\u0026to_addrs_ids=\u0026to_addrs_names=\u0026to_addrs_emails=\u0026to_email_addrs=test%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Accounts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Accounts\",\"parent_id\":\"\",\"parent_name\":\"test\",\"to_addrs_ids\":\"\",\"to_addrs_names\":\"\",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"test \u003Ctest\u003E\",\"return_module\":\"Accounts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
884 884
 		$actual = $user->getEmailLink("name", $account);
885
-		$this->assertSame($expected,$actual);
885
+		$this->assertSame($expected, $actual);
886 886
 
887 887
 
888 888
 		//test with contacts module
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 
892 892
 		$expected = "<a href='javascript:void(0);' onclick='SUGAR.quickCompose.init({\"fullComposeUrl\":\"contact_id=\u0026parent_type=Contacts\u0026parent_id=\u0026parent_name=+\u0026to_addrs_ids=\u0026to_addrs_names=+\u0026to_addrs_emails=\u0026to_email_addrs=+%26nbsp%3B%26lt%3Btest%26gt%3B\u0026return_module=Contacts\u0026return_action=DetailView\u0026return_id=\",\"composePackage\":{\"contact_id\":\"\",\"parent_type\":\"Contacts\",\"parent_id\":\"\",\"parent_name\":\" \",\"to_addrs_ids\":\"\",\"to_addrs_names\":\" \",\"to_addrs_emails\":\"\",\"to_email_addrs\":\"  \u003Ctest\u003E\",\"return_module\":\"Contacts\",\"return_action\":\"DetailView\",\"return_id\":\"\"}});' class=''>";
893 893
 		$actual = $user->getEmailLink("name", $contact);
894
-		$this->assertSame($expected,$actual);
894
+		$this->assertSame($expected, $actual);
895 895
 
896 896
 	}
897 897
 
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 
902 902
 		$result = $user->getLocaleFormatDesc();
903 903
 		$this->assertTrue(isset($result));
904
-		$this->assertGreaterThan(0,strlen($result));
904
+		$this->assertGreaterThan(0, strlen($result));
905 905
 
906 906
 	}
907 907
 
@@ -1067,10 +1067,10 @@  discard block
 block discarded – undo
1067 1067
     	//generate apsswords and verify they are not same
1068 1068
 
1069 1069
     	$password1 = User::generatePassword();
1070
-    	$this->assertGreaterThan(0,strlen($password1));
1070
+    	$this->assertGreaterThan(0, strlen($password1));
1071 1071
 
1072 1072
     	$password2 = User::generatePassword();
1073
-    	$this->assertGreaterThan(0,strlen($password2));
1073
+    	$this->assertGreaterThan(0, strlen($password2));
1074 1074
 
1075 1075
     	$this->assertNotEquals($password1, $password2);
1076 1076
 
Please login to merge, or discard this patch.
tests/tests/modules/ProspectLists/ProspectListTest.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -179,8 +179,7 @@  discard block
 block discarded – undo
179 179
 		try {
180 180
 			$prospectList->mark_relationships_deleted('');
181 181
 			$this->assertTrue(true);
182
-		}
183
-		catch (Exception $e) {
182
+		} catch (Exception $e) {
184 183
 			$this->fail();
185 184
 		}
186 185
 		 
@@ -196,8 +195,7 @@  discard block
 block discarded – undo
196 195
 		try {
197 196
 			$prospectList->fill_in_additional_list_fields();
198 197
 			$this->assertTrue(true);
199
-		}
200
-		catch (Exception $e) {
198
+		} catch (Exception $e) {
201 199
 			$this->fail();
202 200
 		}
203 201
 		 
@@ -224,8 +222,7 @@  discard block
 block discarded – undo
224 222
 		try {
225 223
 			$prospectList->update_currency_id('','');
226 224
 			$this->assertTrue(true);
227
-		}
228
-		catch (Exception $e) {
225
+		} catch (Exception $e) {
229 226
 			$this->fail();
230 227
 		}
231 228
 		 
Please login to merge, or discard this patch.
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -3,79 +3,79 @@  discard block
 block discarded – undo
3 3
 class ProspectListTest extends PHPUnit_Framework_TestCase {
4 4
 
5 5
 
6
-	public function testProspectList()
7
-	{
6
+    public function testProspectList()
7
+    {
8 8
 
9
-		//execute the contructor and check for the Object type and  attributes
10
-		$prospectList = new ProspectList();
9
+        //execute the contructor and check for the Object type and  attributes
10
+        $prospectList = new ProspectList();
11 11
 
12
-		$this->assertInstanceOf('ProspectList',$prospectList);
13
-		$this->assertInstanceOf('SugarBean',$prospectList);
12
+        $this->assertInstanceOf('ProspectList',$prospectList);
13
+        $this->assertInstanceOf('SugarBean',$prospectList);
14 14
 
15
-		$this->assertAttributeEquals('prospect_lists', 'table_name', $prospectList);
16
-		$this->assertAttributeEquals('ProspectLists', 'module_dir', $prospectList);
17
-		$this->assertAttributeEquals('ProspectList', 'object_name', $prospectList);
15
+        $this->assertAttributeEquals('prospect_lists', 'table_name', $prospectList);
16
+        $this->assertAttributeEquals('ProspectLists', 'module_dir', $prospectList);
17
+        $this->assertAttributeEquals('ProspectList', 'object_name', $prospectList);
18 18
 
19
-		$this->assertAttributeEquals("prospect_lists_prospects", 'rel_prospects_table', $prospectList);
19
+        $this->assertAttributeEquals("prospect_lists_prospects", 'rel_prospects_table', $prospectList);
20 20
 
21
-	}
21
+    }
22 22
 
23
-	public function testget_summary_text()
24
-	{
25
-		error_reporting(E_ERROR | E_PARSE);
23
+    public function testget_summary_text()
24
+    {
25
+        error_reporting(E_ERROR | E_PARSE);
26 26
 
27
-		$prospectList = new ProspectList();
27
+        $prospectList = new ProspectList();
28 28
 
29
-		//test without setting name
30
-		$this->assertEquals(Null,$prospectList->get_summary_text());
29
+        //test without setting name
30
+        $this->assertEquals(Null,$prospectList->get_summary_text());
31 31
 
32
-		//test with name set
33
-		$prospectList->name = "test";
34
-		$this->assertEquals('test',$prospectList->get_summary_text());
35
-	}
32
+        //test with name set
33
+        $prospectList->name = "test";
34
+        $this->assertEquals('test',$prospectList->get_summary_text());
35
+    }
36 36
 
37
-	public function testcreate_list_query()
38
-	{
37
+    public function testcreate_list_query()
38
+    {
39 39
 
40
-		$prospectList = new ProspectList();
40
+        $prospectList = new ProspectList();
41 41
 
42
-		//test with empty string params
43
-		$expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where prospect_lists.deleted=0 ORDER BY prospect_lists.name";
44
-		$actual = $prospectList->create_list_query('','');
45
-		$this->assertSame($expected,$actual);
42
+        //test with empty string params
43
+        $expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where prospect_lists.deleted=0 ORDER BY prospect_lists.name";
44
+        $actual = $prospectList->create_list_query('','');
45
+        $this->assertSame($expected,$actual);
46 46
 
47 47
 
48
-		//test with valid string params
49
-		$expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where users.user_name = \"\" AND prospect_lists.deleted=0 ORDER BY prospect_lists.id";
50
-		$actual = $prospectList->create_list_query('prospect_lists.id','users.user_name = ""');
51
-		$this->assertSame($expected,$actual);
48
+        //test with valid string params
49
+        $expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where users.user_name = \"\" AND prospect_lists.deleted=0 ORDER BY prospect_lists.id";
50
+        $actual = $prospectList->create_list_query('prospect_lists.id','users.user_name = ""');
51
+        $this->assertSame($expected,$actual);
52 52
 
53
-	}
53
+    }
54 54
 
55 55
 
56
-	public function testcreate_export_query()
57
-	{
56
+    public function testcreate_export_query()
57
+    {
58 58
 
59
-		$prospectList = new ProspectList();
59
+        $prospectList = new ProspectList();
60 60
 
61
-		//test with empty string params
62
-		$expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE  prospect_lists.deleted=0 ORDER BY prospect_lists.name";
63
-		$actual = $prospectList->create_export_query('','');
64
-		$this->assertSame($expected,$actual);
61
+        //test with empty string params
62
+        $expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE  prospect_lists.deleted=0 ORDER BY prospect_lists.name";
63
+        $actual = $prospectList->create_export_query('','');
64
+        $this->assertSame($expected,$actual);
65 65
 
66 66
 
67
-		//test with valid string params
68
-		$expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE users.user_name = \"\" AND  prospect_lists.deleted=0 ORDER BY prospect_lists.id";
69
-		$actual = $prospectList->create_export_query('prospect_lists.id','users.user_name = ""');
70
-		$this->assertSame($expected,$actual);
67
+        //test with valid string params
68
+        $expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE users.user_name = \"\" AND  prospect_lists.deleted=0 ORDER BY prospect_lists.id";
69
+        $actual = $prospectList->create_export_query('prospect_lists.id','users.user_name = ""');
70
+        $this->assertSame($expected,$actual);
71 71
 
72 72
     }
73 73
 
74 74
     /**
75 75
      * @todo: NEEDS FIXING!
76 76
      */
77
-	public function testcreate_export_members_query()
78
-	{
77
+    public function testcreate_export_members_query()
78
+    {
79 79
         /*
80 80
     	$prospectList = new ProspectList();
81 81
 
@@ -85,208 +85,208 @@  discard block
 block discarded – undo
85 85
     	$this->assertSame($expected,$actual);
86 86
         */
87 87
         $this->assertTrue(true, "NEEDS FIXING!");
88
-	}
88
+    }
89 89
 
90
-	public function testsave() {
90
+    public function testsave() {
91 91
 
92
-		$prospectList = new ProspectList();
92
+        $prospectList = new ProspectList();
93 93
 
94
-		$prospectList->name = "test";
95
-		$prospectList->description ="test description";
94
+        $prospectList->name = "test";
95
+        $prospectList->description ="test description";
96 96
 
97
-		$result = $prospectList->save();
97
+        $result = $prospectList->save();
98 98
 
99
-		//test for record ID to verify that record is saved
100
-		$this->assertTrue(isset($prospectList->id));
101
-		$this->assertEquals(36, strlen($prospectList->id));
99
+        //test for record ID to verify that record is saved
100
+        $this->assertTrue(isset($prospectList->id));
101
+        $this->assertEquals(36, strlen($prospectList->id));
102 102
 
103 103
 
104
-		//test set_prospect_relationship method
105
-		$this->set_prospect_relationship($prospectList->id);
104
+        //test set_prospect_relationship method
105
+        $this->set_prospect_relationship($prospectList->id);
106 106
 
107 107
 
108
-		//test set_prospect_relationship_single method
109
-		$this->set_prospect_relationship_single($prospectList->id);
108
+        //test set_prospect_relationship_single method
109
+        $this->set_prospect_relationship_single($prospectList->id);
110 110
 
111 111
 
112
-		//mark the record as deleted and verify that this record cannot be retrieved anymore.
113
-		$prospectList->mark_deleted($prospectList->id);
114
-		$result = $prospectList->retrieve($prospectList->id);
115
-		$this->assertEquals(null,$result);
112
+        //mark the record as deleted and verify that this record cannot be retrieved anymore.
113
+        $prospectList->mark_deleted($prospectList->id);
114
+        $result = $prospectList->retrieve($prospectList->id);
115
+        $this->assertEquals(null,$result);
116 116
 
117
-	}
117
+    }
118 118
 
119 119
 
120
-	public function testsave_relationship_changes()
120
+    public function testsave_relationship_changes()
121 121
     {
122
-    	$this->markTestIncomplete('Error in query: columns mismatch | Error in methodd call params: 2nd param should be array but string given');
122
+        $this->markTestIncomplete('Error in query: columns mismatch | Error in methodd call params: 2nd param should be array but string given');
123 123
     }
124 124
 
125
-	public function set_prospect_relationship($id)
126
-	{
127
-		$prospectList = new ProspectList();
125
+    public function set_prospect_relationship($id)
126
+    {
127
+        $prospectList = new ProspectList();
128 128
 
129
-		//preset the required attributes, retrive the bean by id and verify the count of records
130
-		$link_ids = array('1','2');
129
+        //preset the required attributes, retrive the bean by id and verify the count of records
130
+        $link_ids = array('1','2');
131 131
 
132
-		$prospectList->retrieve($id);
133
-		$prospectList->set_prospect_relationship($id, $link_ids ,'related');
132
+        $prospectList->retrieve($id);
133
+        $prospectList->set_prospect_relationship($id, $link_ids ,'related');
134 134
 
135
-		$expected_count = $prospectList->get_entry_count();
135
+        $expected_count = $prospectList->get_entry_count();
136 136
 
137
-		$this->assertEquals(2,$expected_count);
137
+        $this->assertEquals(2,$expected_count);
138 138
 
139 139
 
140
-		//test clear_prospect_relationship method with expected counts
141
-		$this->clear_prospect_relationship($id, '1');
142
-		$this->clear_prospect_relationship($id, '2');
140
+        //test clear_prospect_relationship method with expected counts
141
+        $this->clear_prospect_relationship($id, '1');
142
+        $this->clear_prospect_relationship($id, '2');
143 143
 
144
-	}
144
+    }
145 145
 
146
-	public function set_prospect_relationship_single($id)
147
-	{
148
-		$prospectList = new ProspectList();
146
+    public function set_prospect_relationship_single($id)
147
+    {
148
+        $prospectList = new ProspectList();
149 149
 
150
-		$prospectList->retrieve($id);
151
-		$prospectList->set_prospect_relationship_single($id, '3' ,'related');
150
+        $prospectList->retrieve($id);
151
+        $prospectList->set_prospect_relationship_single($id, '3' ,'related');
152 152
 
153
-		$expected_count = $prospectList->get_entry_count();
153
+        $expected_count = $prospectList->get_entry_count();
154 154
 
155
-		$this->assertEquals(1,$expected_count);
155
+        $this->assertEquals(1,$expected_count);
156 156
 
157
-		$this->clear_prospect_relationship($id, '3');
157
+        $this->clear_prospect_relationship($id, '3');
158 158
 
159
-	}
159
+    }
160 160
 
161 161
 
162
-	public function clear_prospect_relationship($id, $related_id)
163
-	{
164
-		$prospectList = new ProspectList();
162
+    public function clear_prospect_relationship($id, $related_id)
163
+    {
164
+        $prospectList = new ProspectList();
165 165
 
166
-		//retrieve the bean and get counts before and after method execution for comparison.
166
+        //retrieve the bean and get counts before and after method execution for comparison.
167 167
 
168
-		$prospectList->retrieve($id);
168
+        $prospectList->retrieve($id);
169 169
 
170
-		$initial_count = (int)$prospectList->get_entry_count();
170
+        $initial_count = (int)$prospectList->get_entry_count();
171 171
 
172
-		$prospectList->clear_prospect_relationship($id, $related_id, 'related');
172
+        $prospectList->clear_prospect_relationship($id, $related_id, 'related');
173 173
 
174
-		$expected_count = (int)$prospectList->get_entry_count();
175
-		$this->assertEquals($initial_count - 1 , $expected_count);
176
-	}
174
+        $expected_count = (int)$prospectList->get_entry_count();
175
+        $this->assertEquals($initial_count - 1 , $expected_count);
176
+    }
177 177
 
178 178
 
179
-	public function testmark_relationships_deleted()
180
-	{
181
-		$prospectList = new ProspectList();
179
+    public function testmark_relationships_deleted()
180
+    {
181
+        $prospectList = new ProspectList();
182 182
 
183
-		//execute the method and test if it works and does not throws an exception.
184
-		try {
185
-			$prospectList->mark_relationships_deleted('');
186
-			$this->assertTrue(true);
187
-		}
188
-		catch (Exception $e) {
189
-			$this->fail();
190
-		}
183
+        //execute the method and test if it works and does not throws an exception.
184
+        try {
185
+            $prospectList->mark_relationships_deleted('');
186
+            $this->assertTrue(true);
187
+        }
188
+        catch (Exception $e) {
189
+            $this->fail();
190
+        }
191 191
 
192
-		$this->markTestIncomplete('Method has no implementation');
192
+        $this->markTestIncomplete('Method has no implementation');
193 193
 
194
-	}
194
+    }
195 195
 
196
-	public function testfill_in_additional_list_fields()
197
-	{
198
-		$prospectList = new ProspectList();
196
+    public function testfill_in_additional_list_fields()
197
+    {
198
+        $prospectList = new ProspectList();
199 199
 
200
-		//execute the method and test if it works and does not throws an exception.
201
-		try {
202
-			$prospectList->fill_in_additional_list_fields();
203
-			$this->assertTrue(true);
204
-		}
205
-		catch (Exception $e) {
206
-			$this->fail();
207
-		}
200
+        //execute the method and test if it works and does not throws an exception.
201
+        try {
202
+            $prospectList->fill_in_additional_list_fields();
203
+            $this->assertTrue(true);
204
+        }
205
+        catch (Exception $e) {
206
+            $this->fail();
207
+        }
208 208
 
209
-		$this->markTestIncomplete('Method has no implementation');
209
+        $this->markTestIncomplete('Method has no implementation');
210 210
 
211
-	}
211
+    }
212 212
 
213
-	public function testfill_in_additional_detail_fields()
214
-	{
215
-		$prospectList = new ProspectList();
213
+    public function testfill_in_additional_detail_fields()
214
+    {
215
+        $prospectList = new ProspectList();
216 216
 
217
-		$prospectList->fill_in_additional_detail_fields();
218
-		$this->assertEquals(0,$prospectList->entry_count);
217
+        $prospectList->fill_in_additional_detail_fields();
218
+        $this->assertEquals(0,$prospectList->entry_count);
219 219
 
220
-	}
220
+    }
221 221
 
222 222
 
223
-	public function testupdate_currency_id()
224
-	{
223
+    public function testupdate_currency_id()
224
+    {
225 225
 
226
-		$prospectList = new ProspectList();
226
+        $prospectList = new ProspectList();
227 227
 
228
-		//execute the method and test if it works and does not throws an exception.
229
-		try {
230
-			$prospectList->update_currency_id('','');
231
-			$this->assertTrue(true);
232
-		}
233
-		catch (Exception $e) {
234
-			$this->fail();
235
-		}
228
+        //execute the method and test if it works and does not throws an exception.
229
+        try {
230
+            $prospectList->update_currency_id('','');
231
+            $this->assertTrue(true);
232
+        }
233
+        catch (Exception $e) {
234
+            $this->fail();
235
+        }
236 236
 
237
-		$this->markTestIncomplete('Method has no implementation');
237
+        $this->markTestIncomplete('Method has no implementation');
238 238
 
239
-	}
239
+    }
240 240
 
241 241
 
242
-	public function testget_entry_count()
243
-	{
244
-		$prospectList = new ProspectList();
242
+    public function testget_entry_count()
243
+    {
244
+        $prospectList = new ProspectList();
245 245
 
246
-		$result = $prospectList->get_entry_count();
247
-		$this->assertEquals(0, $result);
246
+        $result = $prospectList->get_entry_count();
247
+        $this->assertEquals(0, $result);
248 248
 
249
-	}
249
+    }
250 250
 
251 251
 
252
-	public function testget_list_view_data(){
252
+    public function testget_list_view_data(){
253 253
 
254
-		$prospectList = new ProspectList();
254
+        $prospectList = new ProspectList();
255 255
 
256
-		$expected = array( "DELETED"=> 0, "ENTRY_COUNT"=> '0' );
257
-		$actual = $prospectList->get_list_view_data();
258
-		$this->assertSame($expected, $actual);
256
+        $expected = array( "DELETED"=> 0, "ENTRY_COUNT"=> '0' );
257
+        $actual = $prospectList->get_list_view_data();
258
+        $this->assertSame($expected, $actual);
259 259
 
260
-	}
260
+    }
261 261
 
262
-	public function testbuild_generic_where_clause()
263
-	{
262
+    public function testbuild_generic_where_clause()
263
+    {
264 264
 
265
-		$prospectList = new ProspectList();
265
+        $prospectList = new ProspectList();
266 266
 
267
-		//test with empty string params
268
-		$expected = "prospect_lists.name like '%'";
269
-		$actual = $prospectList->build_generic_where_clause('');
270
-		$this->assertSame($expected,$actual);
267
+        //test with empty string params
268
+        $expected = "prospect_lists.name like '%'";
269
+        $actual = $prospectList->build_generic_where_clause('');
270
+        $this->assertSame($expected,$actual);
271 271
 
272 272
 
273
-		//test with valid string params
274
-		$expected = "prospect_lists.name like '%'";
275
-		$actual = $prospectList->build_generic_where_clause('1');
276
-		$this->assertSame($expected,$actual);
273
+        //test with valid string params
274
+        $expected = "prospect_lists.name like '%'";
275
+        $actual = $prospectList->build_generic_where_clause('1');
276
+        $this->assertSame($expected,$actual);
277 277
 
278
-	}
278
+    }
279 279
 
280 280
 
281
-	public function testbean_implements(){
281
+    public function testbean_implements(){
282 282
 
283
-		$prospectList = new ProspectList();
283
+        $prospectList = new ProspectList();
284 284
 
285
-		$this->assertEquals(false, $prospectList->bean_implements('')); //test with blank value
286
-		$this->assertEquals(false, $prospectList->bean_implements('test')); //test with invalid value
287
-		$this->assertEquals(true, $prospectList->bean_implements('ACL')); //test with valid value
285
+        $this->assertEquals(false, $prospectList->bean_implements('')); //test with blank value
286
+        $this->assertEquals(false, $prospectList->bean_implements('test')); //test with invalid value
287
+        $this->assertEquals(true, $prospectList->bean_implements('ACL')); //test with valid value
288 288
 
289
-	}
289
+    }
290 290
 
291 291
 }
292 292
 
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 		//execute the contructor and check for the Object type and  attributes
10 10
 		$prospectList = new ProspectList();
11 11
 
12
-		$this->assertInstanceOf('ProspectList',$prospectList);
13
-		$this->assertInstanceOf('SugarBean',$prospectList);
12
+		$this->assertInstanceOf('ProspectList', $prospectList);
13
+		$this->assertInstanceOf('SugarBean', $prospectList);
14 14
 
15 15
 		$this->assertAttributeEquals('prospect_lists', 'table_name', $prospectList);
16 16
 		$this->assertAttributeEquals('ProspectLists', 'module_dir', $prospectList);
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 		$prospectList = new ProspectList();
28 28
 
29 29
 		//test without setting name
30
-		$this->assertEquals(Null,$prospectList->get_summary_text());
30
+		$this->assertEquals(Null, $prospectList->get_summary_text());
31 31
 
32 32
 		//test with name set
33 33
 		$prospectList->name = "test";
34
-		$this->assertEquals('test',$prospectList->get_summary_text());
34
+		$this->assertEquals('test', $prospectList->get_summary_text());
35 35
 	}
36 36
 
37 37
 	public function testcreate_list_query()
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 
42 42
 		//test with empty string params
43 43
 		$expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where prospect_lists.deleted=0 ORDER BY prospect_lists.name";
44
-		$actual = $prospectList->create_list_query('','');
45
-		$this->assertSame($expected,$actual);
44
+		$actual = $prospectList->create_list_query('', '');
45
+		$this->assertSame($expected, $actual);
46 46
 
47 47
 
48 48
 		//test with valid string params
49 49
 		$expected = "SELECT users.user_name as assigned_user_name, prospect_lists.* FROM prospect_lists LEFT JOIN users\n					ON prospect_lists.assigned_user_id=users.id where users.user_name = \"\" AND prospect_lists.deleted=0 ORDER BY prospect_lists.id";
50
-		$actual = $prospectList->create_list_query('prospect_lists.id','users.user_name = ""');
51
-		$this->assertSame($expected,$actual);
50
+		$actual = $prospectList->create_list_query('prospect_lists.id', 'users.user_name = ""');
51
+		$this->assertSame($expected, $actual);
52 52
 
53 53
 	}
54 54
 
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 
61 61
 		//test with empty string params
62 62
 		$expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE  prospect_lists.deleted=0 ORDER BY prospect_lists.name";
63
-		$actual = $prospectList->create_export_query('','');
64
-		$this->assertSame($expected,$actual);
63
+		$actual = $prospectList->create_export_query('', '');
64
+		$this->assertSame($expected, $actual);
65 65
 
66 66
 
67 67
 		//test with valid string params
68 68
 		$expected = "SELECT\n                                prospect_lists.*,\n                                users.user_name as assigned_user_name FROM prospect_lists LEFT JOIN users\n                                ON prospect_lists.assigned_user_id=users.id  WHERE users.user_name = \"\" AND  prospect_lists.deleted=0 ORDER BY prospect_lists.id";
69
-		$actual = $prospectList->create_export_query('prospect_lists.id','users.user_name = ""');
70
-		$this->assertSame($expected,$actual);
69
+		$actual = $prospectList->create_export_query('prospect_lists.id', 'users.user_name = ""');
70
+		$this->assertSame($expected, $actual);
71 71
 
72 72
     }
73 73
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		$prospectList = new ProspectList();
93 93
 
94 94
 		$prospectList->name = "test";
95
-		$prospectList->description ="test description";
95
+		$prospectList->description = "test description";
96 96
 
97 97
 		$result = $prospectList->save();
98 98
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		//mark the record as deleted and verify that this record cannot be retrieved anymore.
113 113
 		$prospectList->mark_deleted($prospectList->id);
114 114
 		$result = $prospectList->retrieve($prospectList->id);
115
-		$this->assertEquals(null,$result);
115
+		$this->assertEquals(null, $result);
116 116
 
117 117
 	}
118 118
 
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 		$prospectList = new ProspectList();
128 128
 
129 129
 		//preset the required attributes, retrive the bean by id and verify the count of records
130
-		$link_ids = array('1','2');
130
+		$link_ids = array('1', '2');
131 131
 
132 132
 		$prospectList->retrieve($id);
133
-		$prospectList->set_prospect_relationship($id, $link_ids ,'related');
133
+		$prospectList->set_prospect_relationship($id, $link_ids, 'related');
134 134
 
135 135
 		$expected_count = $prospectList->get_entry_count();
136 136
 
137
-		$this->assertEquals(2,$expected_count);
137
+		$this->assertEquals(2, $expected_count);
138 138
 
139 139
 
140 140
 		//test clear_prospect_relationship method with expected counts
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 		$prospectList = new ProspectList();
149 149
 
150 150
 		$prospectList->retrieve($id);
151
-		$prospectList->set_prospect_relationship_single($id, '3' ,'related');
151
+		$prospectList->set_prospect_relationship_single($id, '3', 'related');
152 152
 
153 153
 		$expected_count = $prospectList->get_entry_count();
154 154
 
155
-		$this->assertEquals(1,$expected_count);
155
+		$this->assertEquals(1, $expected_count);
156 156
 
157 157
 		$this->clear_prospect_relationship($id, '3');
158 158
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$prospectList->clear_prospect_relationship($id, $related_id, 'related');
173 173
 
174 174
 		$expected_count = (int)$prospectList->get_entry_count();
175
-		$this->assertEquals($initial_count - 1 , $expected_count);
175
+		$this->assertEquals($initial_count - 1, $expected_count);
176 176
 	}
177 177
 
178 178
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 		$prospectList = new ProspectList();
216 216
 
217 217
 		$prospectList->fill_in_additional_detail_fields();
218
-		$this->assertEquals(0,$prospectList->entry_count);
218
+		$this->assertEquals(0, $prospectList->entry_count);
219 219
 
220 220
 	}
221 221
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 		//execute the method and test if it works and does not throws an exception.
229 229
 		try {
230
-			$prospectList->update_currency_id('','');
230
+			$prospectList->update_currency_id('', '');
231 231
 			$this->assertTrue(true);
232 232
 		}
233 233
 		catch (Exception $e) {
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	}
250 250
 
251 251
 
252
-	public function testget_list_view_data(){
252
+	public function testget_list_view_data() {
253 253
 
254 254
 		$prospectList = new ProspectList();
255 255
 
256
-		$expected = array( "DELETED"=> 0, "ENTRY_COUNT"=> '0' );
256
+		$expected = array("DELETED"=> 0, "ENTRY_COUNT"=> '0');
257 257
 		$actual = $prospectList->get_list_view_data();
258 258
 		$this->assertSame($expected, $actual);
259 259
 
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
 		//test with empty string params
268 268
 		$expected = "prospect_lists.name like '%'";
269 269
 		$actual = $prospectList->build_generic_where_clause('');
270
-		$this->assertSame($expected,$actual);
270
+		$this->assertSame($expected, $actual);
271 271
 
272 272
 
273 273
 		//test with valid string params
274 274
 		$expected = "prospect_lists.name like '%'";
275 275
 		$actual = $prospectList->build_generic_where_clause('1');
276
-		$this->assertSame($expected,$actual);
276
+		$this->assertSame($expected, $actual);
277 277
 
278 278
 	}
279 279
 
280 280
 
281
-	public function testbean_implements(){
281
+	public function testbean_implements() {
282 282
 
283 283
 		$prospectList = new ProspectList();
284 284
 
Please login to merge, or discard this patch.
tests/tests/modules/Employees/EmployeeTest.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 		try {
44 44
 			$employee->fill_in_additional_list_fields();
45 45
 			$this->assertTrue(true);
46
-		}
47
-		catch (Exception $e) {
46
+		} catch (Exception $e) {
48 47
 			$this->fail();
49 48
 		}
50 49
 		
@@ -118,8 +117,7 @@  discard block
 block discarded – undo
118 117
 		try {
119 118
 			$employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection);
120 119
 			$this->assertTrue(true);
121
-		}
122
-		catch (Exception $e) {
120
+		} catch (Exception $e) {
123 121
 			$this->fail();
124 122
 		}
125 123
 		
@@ -151,8 +149,7 @@  discard block
 block discarded – undo
151 149
 		try {
152 150
 			$employee->preprocess_fields_on_save();
153 151
 			$this->assertTrue(true);
154
-		}
155
-		catch (Exception $e) {
152
+		} catch (Exception $e) {
156 153
 			$this->fail();
157 154
 		}
158 155
 
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -3,165 +3,165 @@  discard block
 block discarded – undo
3 3
 class EmployeeTest extends PHPUnit_Framework_TestCase {
4 4
 
5 5
 
6
-	public function testEmployee() {
6
+    public function testEmployee() {
7 7
 
8
-		//execute the contructor and check for the Object type and  attributes
9
-		$employee = new Employee();
10
-		$this->assertInstanceOf('Employee',$employee);
11
-		$this->assertInstanceOf('Person',$employee);
12
-		$this->assertInstanceOf('SugarBean',$employee);
8
+        //execute the contructor and check for the Object type and  attributes
9
+        $employee = new Employee();
10
+        $this->assertInstanceOf('Employee',$employee);
11
+        $this->assertInstanceOf('Person',$employee);
12
+        $this->assertInstanceOf('SugarBean',$employee);
13 13
 
14
-		$this->assertAttributeEquals('Employees', 'module_dir', $employee);
15
-		$this->assertAttributeEquals('Employee', 'object_name', $employee);
16
-		$this->assertAttributeEquals('users', 'table_name', $employee);
17
-		$this->assertAttributeEquals(true, 'new_schema', $employee);
14
+        $this->assertAttributeEquals('Employees', 'module_dir', $employee);
15
+        $this->assertAttributeEquals('Employee', 'object_name', $employee);
16
+        $this->assertAttributeEquals('users', 'table_name', $employee);
17
+        $this->assertAttributeEquals(true, 'new_schema', $employee);
18 18
 
19
-	}
19
+    }
20 20
 
21 21
 
22
-	public function testget_summary_text() {
22
+    public function testget_summary_text() {
23 23
 
24
-		error_reporting(E_ERROR | E_PARSE);
24
+        error_reporting(E_ERROR | E_PARSE);
25 25
 
26
-		$employee = new Employee();
26
+        $employee = new Employee();
27 27
 
28
-		//test without setting name
29
-		$this->assertEquals(' ',$employee->get_summary_text());
28
+        //test without setting name
29
+        $this->assertEquals(' ',$employee->get_summary_text());
30 30
 
31
-		//test with name set
32
-		$employee->retrieve(1);
33
-		$this->assertEquals('Administrator',$employee->get_summary_text());
31
+        //test with name set
32
+        $employee->retrieve(1);
33
+        $this->assertEquals('Administrator',$employee->get_summary_text());
34 34
 
35 35
     }
36 36
 
37 37
 
38
-	public function testfill_in_additional_list_fields() {
39
-
40
-		$employee = new Employee();
41
-
42
-		//execute the method and test if it works and does not throws an exception.
43
-		try {
44
-			$employee->fill_in_additional_list_fields();
45
-			$this->assertTrue(true);
46
-		}
47
-		catch (Exception $e) {
48
-			$this->fail();
49
-		}
50
-
51
-	}
38
+    public function testfill_in_additional_list_fields() {
52 39
 
53
-	public function testfill_in_additional_detail_fields()
54
-	{
55
-		$employee = new Employee();
40
+        $employee = new Employee();
56 41
 
42
+        //execute the method and test if it works and does not throws an exception.
43
+        try {
44
+            $employee->fill_in_additional_list_fields();
45
+            $this->assertTrue(true);
46
+        }
47
+        catch (Exception $e) {
48
+            $this->fail();
49
+        }
57 50
 
58
-		//test with a empty employee bean
59
-		$employee->fill_in_additional_detail_fields();
60
-		$this->assertEquals("", $employee->reports_to_name);
51
+    }
61 52
 
53
+    public function testfill_in_additional_detail_fields()
54
+    {
55
+        $employee = new Employee();
62 56
 
63
-		//test with a valid employee bean
64
-		$employee->retrieve(1);
65
-		$employee->fill_in_additional_detail_fields();
66
-		$this->assertEquals("", $employee->reports_to_name);
67 57
 
68
-	}
58
+        //test with a empty employee bean
59
+        $employee->fill_in_additional_detail_fields();
60
+        $this->assertEquals("", $employee->reports_to_name);
69 61
 
70
-	public function testretrieve_employee_id()
71
-	{
72
-		$employee = new Employee();
73
-		//$this->assertEquals('1' ,$employee->retrieve_employee_id('admin'));
74 62
 
75
-		$this->markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name');
63
+        //test with a valid employee bean
64
+        $employee->retrieve(1);
65
+        $employee->fill_in_additional_detail_fields();
66
+        $this->assertEquals("", $employee->reports_to_name);
76 67
 
77
-	}
68
+    }
78 69
 
70
+    public function testretrieve_employee_id()
71
+    {
72
+        $employee = new Employee();
73
+        //$this->assertEquals('1' ,$employee->retrieve_employee_id('admin'));
79 74
 
80
-	public function testverify_data()
81
-	{
82
-		$employee = new Employee();
83
-		$this->assertEquals(true ,$employee->verify_data() );
75
+        $this->markTestSkipped('Bug in query: employee_name parameter is wrongly used as user_name');
84 76
 
85
-	}
77
+    }
86 78
 
87
-	public function testget_list_view_data(){
88 79
 
89
-		$employee = new Employee();
80
+    public function testverify_data()
81
+    {
82
+        $employee = new Employee();
83
+        $this->assertEquals(true ,$employee->verify_data() );
90 84
 
91
-		$expected = array (
92
-					  'SUGAR_LOGIN' => '1',
93
-					  'FULL_NAME' => ' ',
94
-					  'NAME' => ' ',
95
-					  'IS_ADMIN' => '0',
96
-					  'EXTERNAL_AUTH_ONLY' => '0',
97
-					  'RECEIVE_NOTIFICATIONS' => '1',
98
-					  'DELETED' => 0,
99
-					  'PORTAL_ONLY' => '0',
100
-					  'SHOW_ON_EMPLOYEES' => '1',
101
-					  'ENCODED_NAME' => ' ',
102
-					  'EMAIL1' => '',
103
-					  'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Employees\\u0026parent_id=\\u0026parent_name=+\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=+%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Employees\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Employees","parent_id":"","parent_name":" ","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":"  \\u003C\\u003E","return_module":"Employees","return_action":"ListView","return_id":""}});\' class=\'\'>',
104
-					  'MESSENGER_TYPE' => '',
105
-					  'REPORTS_TO_NAME' => NULL,
106
-					);
85
+    }
107 86
 
108
-		$actual = $employee->get_list_view_data();
109
-		$this->assertSame($expected, $actual);
87
+    public function testget_list_view_data(){
88
+
89
+        $employee = new Employee();
90
+
91
+        $expected = array (
92
+                        'SUGAR_LOGIN' => '1',
93
+                        'FULL_NAME' => ' ',
94
+                        'NAME' => ' ',
95
+                        'IS_ADMIN' => '0',
96
+                        'EXTERNAL_AUTH_ONLY' => '0',
97
+                        'RECEIVE_NOTIFICATIONS' => '1',
98
+                        'DELETED' => 0,
99
+                        'PORTAL_ONLY' => '0',
100
+                        'SHOW_ON_EMPLOYEES' => '1',
101
+                        'ENCODED_NAME' => ' ',
102
+                        'EMAIL1' => '',
103
+                        'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Employees\\u0026parent_id=\\u0026parent_name=+\\u0026to_addrs_ids=\\u0026to_addrs_names=\\u0026to_addrs_emails=\\u0026to_email_addrs=+%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Employees\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Employees","parent_id":"","parent_name":" ","to_addrs_ids":"","to_addrs_names":"","to_addrs_emails":"","to_email_addrs":"  \\u003C\\u003E","return_module":"Employees","return_action":"ListView","return_id":""}});\' class=\'\'>',
104
+                        'MESSENGER_TYPE' => '',
105
+                        'REPORTS_TO_NAME' => NULL,
106
+                    );
107
+
108
+        $actual = $employee->get_list_view_data();
109
+        $this->assertSame($expected, $actual);
110 110
 
111
-	}
111
+    }
112 112
 
113
-	public function testlist_view_parse_additional_sections(){
113
+    public function testlist_view_parse_additional_sections(){
114 114
 
115
-		$employee = new Employee();
115
+        $employee = new Employee();
116 116
 
117
-		//execute the method and test if it works and does not throws an exception.
118
-		try {
119
-			$employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection);
120
-			$this->assertTrue(true);
121
-		}
122
-		catch (Exception $e) {
123
-			$this->fail();
124
-		}
117
+        //execute the method and test if it works and does not throws an exception.
118
+        try {
119
+            $employee->list_view_parse_additional_sections(new Sugar_Smarty(), $xTemplateSection);
120
+            $this->assertTrue(true);
121
+        }
122
+        catch (Exception $e) {
123
+            $this->fail();
124
+        }
125 125
 
126
-	}
126
+    }
127 127
 
128 128
 
129
-	public function testcreate_export_query() {
129
+    public function testcreate_export_query() {
130 130
 
131
-		$employee = new Employee();
131
+        $employee = new Employee();
132 132
 
133
-		//test with empty string params
134
-		$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 ORDER BY users.user_name";
135
-		$actual = $employee->create_export_query('','');
136
-		$this->assertSame($expected,$actual);
133
+        //test with empty string params
134
+        $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 ORDER BY users.user_name";
135
+        $actual = $employee->create_export_query('','');
136
+        $this->assertSame($expected,$actual);
137 137
 
138 138
 
139
-		//test with valid string params
140
-		$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE users.user_name=\"\" AND  users.deleted = 0 ORDER BY users.id";
141
-		$actual = $employee->create_export_query('users.id','users.user_name=""');
142
-		$this->assertSame($expected,$actual);
139
+        //test with valid string params
140
+        $expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE users.user_name=\"\" AND  users.deleted = 0 ORDER BY users.id";
141
+        $actual = $employee->create_export_query('users.id','users.user_name=""');
142
+        $this->assertSame($expected,$actual);
143 143
 
144
-	}
144
+    }
145 145
 
146
-	public function testpreprocess_fields_on_save(){
146
+    public function testpreprocess_fields_on_save(){
147 147
 
148
-		$employee = new Employee();
148
+        $employee = new Employee();
149 149
 
150
-		//execute the method and test if it works and does not throws an exception.
151
-		try {
152
-			$employee->preprocess_fields_on_save();
153
-			$this->assertTrue(true);
154
-		}
155
-		catch (Exception $e) {
156
-			$this->fail();
157
-		}
150
+        //execute the method and test if it works and does not throws an exception.
151
+        try {
152
+            $employee->preprocess_fields_on_save();
153
+            $this->assertTrue(true);
154
+        }
155
+        catch (Exception $e) {
156
+            $this->fail();
157
+        }
158 158
 
159
-	}
159
+    }
160 160
 
161 161
     /**
162 162
      * @todo: NEEDS FIXING!
163 163
      */
164
-	public function testcreate_new_list_query()
164
+    public function testcreate_new_list_query()
165 165
     {
166 166
         /*
167 167
     	$employee = new Employee();
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 
184 184
     public function testhasCustomFields()
185 185
     {
186
-    	$employee = new Employee();
187
-    	$result = $employee->hasCustomFields();
188
-    	$this->assertEquals(false,$result);
186
+        $employee = new Employee();
187
+        $result = $employee->hasCustomFields();
188
+        $this->assertEquals(false,$result);
189 189
     }
190 190
 
191 191
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 		//execute the contructor and check for the Object type and  attributes
9 9
 		$employee = new Employee();
10
-		$this->assertInstanceOf('Employee',$employee);
11
-		$this->assertInstanceOf('Person',$employee);
12
-		$this->assertInstanceOf('SugarBean',$employee);
10
+		$this->assertInstanceOf('Employee', $employee);
11
+		$this->assertInstanceOf('Person', $employee);
12
+		$this->assertInstanceOf('SugarBean', $employee);
13 13
 
14 14
 		$this->assertAttributeEquals('Employees', 'module_dir', $employee);
15 15
 		$this->assertAttributeEquals('Employee', 'object_name', $employee);
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 		$employee = new Employee();
27 27
 
28 28
 		//test without setting name
29
-		$this->assertEquals(' ',$employee->get_summary_text());
29
+		$this->assertEquals(' ', $employee->get_summary_text());
30 30
 
31 31
 		//test with name set
32 32
 		$employee->retrieve(1);
33
-		$this->assertEquals('Administrator',$employee->get_summary_text());
33
+		$this->assertEquals('Administrator', $employee->get_summary_text());
34 34
 
35 35
     }
36 36
 
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	public function testverify_data()
81 81
 	{
82 82
 		$employee = new Employee();
83
-		$this->assertEquals(true ,$employee->verify_data() );
83
+		$this->assertEquals(true, $employee->verify_data());
84 84
 
85 85
 	}
86 86
 
87
-	public function testget_list_view_data(){
87
+	public function testget_list_view_data() {
88 88
 
89 89
 		$employee = new Employee();
90 90
 
91
-		$expected = array (
91
+		$expected = array(
92 92
 					  'SUGAR_LOGIN' => '1',
93 93
 					  'FULL_NAME' => ' ',
94 94
 					  'NAME' => ' ',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 	}
112 112
 
113
-	public function testlist_view_parse_additional_sections(){
113
+	public function testlist_view_parse_additional_sections() {
114 114
 
115 115
 		$employee = new Employee();
116 116
 
@@ -132,18 +132,18 @@  discard block
 block discarded – undo
132 132
 
133 133
 		//test with empty string params
134 134
 		$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE  users.deleted = 0 ORDER BY users.user_name";
135
-		$actual = $employee->create_export_query('','');
136
-		$this->assertSame($expected,$actual);
135
+		$actual = $employee->create_export_query('', '');
136
+		$this->assertSame($expected, $actual);
137 137
 
138 138
 
139 139
 		//test with valid string params
140 140
 		$expected = "SELECT id, user_name, first_name, last_name, description, date_entered, date_modified, modified_user_id, created_by, title, department, is_admin, phone_home, phone_mobile, phone_work, phone_other, phone_fax, address_street, address_city, address_state, address_postalcode, address_country, reports_to_id, portal_only, status, receive_notifications, employee_status, messenger_id, messenger_type, is_group FROM users  WHERE users.user_name=\"\" AND  users.deleted = 0 ORDER BY users.id";
141
-		$actual = $employee->create_export_query('users.id','users.user_name=""');
142
-		$this->assertSame($expected,$actual);
141
+		$actual = $employee->create_export_query('users.id', 'users.user_name=""');
142
+		$this->assertSame($expected, $actual);
143 143
 
144 144
 	}
145 145
 
146
-	public function testpreprocess_fields_on_save(){
146
+	public function testpreprocess_fields_on_save() {
147 147
 
148 148
 		$employee = new Employee();
149 149
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     {
186 186
     	$employee = new Employee();
187 187
     	$result = $employee->hasCustomFields();
188
-    	$this->assertEquals(false,$result);
188
+    	$this->assertEquals(false, $result);
189 189
     }
190 190
 
191 191
 }
Please login to merge, or discard this patch.
tests/tests/modules/Contacts/ContactTest.php 3 patches
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -154,8 +154,7 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			$contact->load_contacts_users_relationship();
156 156
 			$this->assertTrue(true);
157
-		}
158
-		catch (Exception $e) {
157
+		} catch (Exception $e) {
159 158
 			$this->fail();
160 159
 		}
161 160
 		
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
 			$contact->save_relationship_changes(true);
255 254
 			$contact->save_relationship_changes(false);
256 255
 			$this->assertTrue(true);
257
-		}
258
-		catch (Exception $e) {
256
+		} catch (Exception $e) {
259 257
 			$this->fail();
260 258
 		}
261 259
 		
@@ -289,8 +287,7 @@  discard block
 block discarded – undo
289 287
     	try {
290 288
    			$contact->process_sync_to_outlook("all");
291 289
     		$this->assertTrue(true);
292
-    	}
293
-    	catch (Exception $e) {
290
+    	} catch (Exception $e) {
294 291
     		$this->fail();
295 292
     	}
296 293
     	 
@@ -299,8 +296,7 @@  discard block
 block discarded – undo
299 296
     	try {
300 297
     		$contact->process_sync_to_outlook("1");
301 298
     		$this->assertTrue(true);
302
-    	}
303
-    	catch (Exception $e) {
299
+    	} catch (Exception $e) {
304 300
     		$this->fail();
305 301
     	}
306 302
     	 	
Please login to merge, or discard this patch.
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -2,68 +2,68 @@  discard block
 block discarded – undo
2 2
 
3 3
 class ContactTest extends PHPUnit_Framework_TestCase {
4 4
 
5
-	public function testContact() {
5
+    public function testContact() {
6 6
 
7
-		//execute the contructor and check for the Object type and  attributes
8
-		$contact = new Contact();
9
-		$this->assertInstanceOf('Contact',$contact);
10
-		$this->assertInstanceOf('Person',$contact);
11
-		$this->assertInstanceOf('SugarBean',$contact);
7
+        //execute the contructor and check for the Object type and  attributes
8
+        $contact = new Contact();
9
+        $this->assertInstanceOf('Contact',$contact);
10
+        $this->assertInstanceOf('Person',$contact);
11
+        $this->assertInstanceOf('SugarBean',$contact);
12 12
 
13
-		$this->assertAttributeEquals('Contacts', 'module_dir', $contact);
14
-		$this->assertAttributeEquals('Contact', 'object_name', $contact);
15
-		$this->assertAttributeEquals('contacts', 'table_name', $contact);
16
-		$this->assertAttributeEquals('accounts_contacts', 'rel_account_table', $contact);
17
-		$this->assertAttributeEquals('opportunities_contacts', 'rel_opportunity_table', $contact);
18
-		$this->assertAttributeEquals(true, 'importable', $contact);
19
-		$this->assertAttributeEquals(true, 'new_schema', $contact);
13
+        $this->assertAttributeEquals('Contacts', 'module_dir', $contact);
14
+        $this->assertAttributeEquals('Contact', 'object_name', $contact);
15
+        $this->assertAttributeEquals('contacts', 'table_name', $contact);
16
+        $this->assertAttributeEquals('accounts_contacts', 'rel_account_table', $contact);
17
+        $this->assertAttributeEquals('opportunities_contacts', 'rel_opportunity_table', $contact);
18
+        $this->assertAttributeEquals(true, 'importable', $contact);
19
+        $this->assertAttributeEquals(true, 'new_schema', $contact);
20 20
 
21
-	}
21
+    }
22 22
 
23
-	public function testadd_list_count_joins()
24
-	{
25
-		error_reporting(E_ERROR | E_PARSE);
23
+    public function testadd_list_count_joins()
24
+    {
25
+        error_reporting(E_ERROR | E_PARSE);
26 26
 
27
-		$contact = new Contact();
27
+        $contact = new Contact();
28 28
 
29
-		//test with empty strings
30
-		$query = "";
31
-		$contact->add_list_count_joins($query, '');
32
-		$this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
29
+        //test with empty strings
30
+        $query = "";
31
+        $contact->add_list_count_joins($query, '');
32
+        $this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
33 33
 
34 34
 
35
-		//test with valid string
36
-		$query = "";
37
-		$expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n                    LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
38
-		$contact->add_list_count_joins($query, 'accounts.name');
39
-		$query = preg_replace('/\s+/', '', $query);
40
-		$expected =preg_replace('/\s+/', '', $expected);
41
-		$this->assertSame($expected,$query);
35
+        //test with valid string
36
+        $query = "";
37
+        $expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n                    LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
38
+        $contact->add_list_count_joins($query, 'accounts.name');
39
+        $query = preg_replace('/\s+/', '', $query);
40
+        $expected =preg_replace('/\s+/', '', $expected);
41
+        $this->assertSame($expected,$query);
42 42
 		
43
-		//test with valid string
44
-		$query = "";
45
-		$expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n	                 LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
46
-		$contact->add_list_count_joins($query, 'contacts.name');
47
-		$this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
43
+        //test with valid string
44
+        $query = "";
45
+        $expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n	                 LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
46
+        $contact->add_list_count_joins($query, 'contacts.name');
47
+        $this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
48 48
 
49 49
 
50
-	}
50
+    }
51 51
 
52
-	public function testlistviewACLHelper()
53
-	{
54
-		$contact = new Contact();
52
+    public function testlistviewACLHelper()
53
+    {
54
+        $contact = new Contact();
55 55
 
56
-		$expected = array( "MAIN"=>"a", "ACCOUNT"=>"a");
57
-		$actual = $contact->listviewACLHelper();
58
-		$this->assertSame($expected,$actual);
56
+        $expected = array( "MAIN"=>"a", "ACCOUNT"=>"a");
57
+        $actual = $contact->listviewACLHelper();
58
+        $this->assertSame($expected,$actual);
59 59
 
60
-	}
60
+    }
61 61
 
62 62
     /**
63 63
      * @todo: NEEDS FIXING!
64 64
      */
65
-	public function testcreate_new_list_query()
66
-	{
65
+    public function testcreate_new_list_query()
66
+    {
67 67
         /*
68 68
 		$contact = new Contact();
69 69
 
@@ -79,239 +79,239 @@  discard block
 block discarded – undo
79 79
 		$this->assertSame($expected,$actual);
80 80
 		*/
81 81
         $this->assertTrue(true, "NEEDS FIXING!");
82
-	}
82
+    }
83 83
 
84 84
 
85
-	public function testaddress_popup_create_new_list_query()
86
-	{
85
+    public function testaddress_popup_create_new_list_query()
86
+    {
87 87
 
88
-		$contact = new Contact();
88
+        $contact = new Contact();
89 89
 
90
-		//test with empty string params
91
-		$expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where  contacts.deleted=0 ";
92
-		$actual = $contact->address_popup_create_new_list_query('','');
93
-		$this->assertSame($expected,$actual);
90
+        //test with empty string params
91
+        $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where  contacts.deleted=0 ";
92
+        $actual = $contact->address_popup_create_new_list_query('','');
93
+        $this->assertSame($expected,$actual);
94 94
 
95 95
 
96
-		//test with valid string params
97
-		$expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND  contacts.deleted=0 ";
98
-		$actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""');
99
-		$this->assertSame($expected,$actual);
96
+        //test with valid string params
97
+        $expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND  contacts.deleted=0 ";
98
+        $actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""');
99
+        $this->assertSame($expected,$actual);
100 100
 
101
-	}
101
+    }
102 102
 
103
-	public function testcreate_export_query()
104
-	{
105
-		$contact = new Contact();
103
+    public function testcreate_export_query()
104
+    {
105
+        $contact = new Contact();
106 106
 
107
-		//test with empty string params
108
-		$expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
109
-		$actual = $contact->create_export_query('','');
110
-		$this->assertSame($expected,$actual);
107
+        //test with empty string params
108
+        $expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
109
+        $actual = $contact->create_export_query('','');
110
+        $this->assertSame($expected,$actual);
111 111
 
112 112
 
113
-		//test with valid string params
114
-		$expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
115
-		$actual = $contact->create_export_query('contacts.id','contacts.name=""');
116
-		$this->assertSame($expected,$actual);
113
+        //test with valid string params
114
+        $expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
115
+        $actual = $contact->create_export_query('contacts.id','contacts.name=""');
116
+        $this->assertSame($expected,$actual);
117 117
 
118
-	}
118
+    }
119 119
 
120
-	public function testfill_in_additional_list_fields() {
120
+    public function testfill_in_additional_list_fields() {
121 121
 
122
-		$contact = new Contact();
122
+        $contact = new Contact();
123 123
 
124
-		//test with attributes preset and verify attributes are set accordingly
125
-		$contact->first_name = "firstn";
126
-		$contact->last_name = "lastn";
127
-		$contact->email1 = "[email protected]";
128
-		$contact->email2 = "[email protected]";
124
+        //test with attributes preset and verify attributes are set accordingly
125
+        $contact->first_name = "firstn";
126
+        $contact->last_name = "lastn";
127
+        $contact->email1 = "[email protected]";
128
+        $contact->email2 = "[email protected]";
129 129
 
130 130
 
131
-		$contact->fill_in_additional_list_fields();
131
+        $contact->fill_in_additional_list_fields();
132 132
 
133
-		$this->assertEquals("firstn lastn",$contact->full_name);
134
-		$this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name1);
135
-		$this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name2);
133
+        $this->assertEquals("firstn lastn",$contact->full_name);
134
+        $this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name1);
135
+        $this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name2);
136 136
 
137
-	}
137
+    }
138 138
 
139
-	public function testfill_in_additional_detail_fields() {
139
+    public function testfill_in_additional_detail_fields() {
140 140
 
141
-		$contact = new Contact();
141
+        $contact = new Contact();
142 142
 
143
-		//test with attributes preset and verify attributes are set accordingly
144
-		$contact->id = "1";
143
+        //test with attributes preset and verify attributes are set accordingly
144
+        $contact->id = "1";
145 145
 
146
-		$contact->fill_in_additional_detail_fields();
146
+        $contact->fill_in_additional_detail_fields();
147 147
 
148
-		$this->assertEquals("",$contact->account_name);
149
-		$this->assertEquals("",$contact->account_id);
150
-		$this->assertEquals("",$contact->report_to_name);
148
+        $this->assertEquals("",$contact->account_name);
149
+        $this->assertEquals("",$contact->account_id);
150
+        $this->assertEquals("",$contact->report_to_name);
151 151
 
152
-	}
152
+    }
153 153
 
154 154
 
155
-	public function testload_contacts_users_relationship(){
155
+    public function testload_contacts_users_relationship(){
156 156
 
157
-		$contact = new Contact();
157
+        $contact = new Contact();
158 158
 
159
-		//execute the method and test if it works and does not throws an exception.
160
-		try {
161
-			$contact->load_contacts_users_relationship();
162
-			$this->assertTrue(true);
163
-		}
164
-		catch (Exception $e) {
165
-			$this->fail();
166
-		}
159
+        //execute the method and test if it works and does not throws an exception.
160
+        try {
161
+            $contact->load_contacts_users_relationship();
162
+            $this->assertTrue(true);
163
+        }
164
+        catch (Exception $e) {
165
+            $this->fail();
166
+        }
167 167
 
168
-	}
168
+    }
169 169
 
170
-	public function testget_list_view_data() {
170
+    public function testget_list_view_data() {
171 171
 
172
-		$contact = new Contact();
172
+        $contact = new Contact();
173 173
 
174
-		//test with attributes preset and verify attributes are set accordingly
175
-		$contact->first_name = "first";
176
-		$contact->last_name = "last";
177
-
178
-		$expected = array (
179
-					  'NAME' => 'first last',
180
-					  'DELETED' => 0,
181
-					  'FIRST_NAME' => 'first',
182
-					  'LAST_NAME' => 'last',
183
-					  'FULL_NAME' => 'first last',
184
-					  'DO_NOT_CALL' => '0',
185
-					  'PORTAL_USER_TYPE' => 'Single user',
186
-					  'ENCODED_NAME' => 'first last',
187
-					  'EMAIL1' => '',
188
-					  'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Contacts\\u0026parent_id=\\u0026parent_name=first+last\\u0026to_addrs_ids=\\u0026to_addrs_names=first+last\\u0026to_addrs_emails=\\u0026to_email_addrs=first+last%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Contacts\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Contacts","parent_id":"","parent_name":"first last","to_addrs_ids":"","to_addrs_names":"first last","to_addrs_emails":"","to_email_addrs":"first last \\u003C\\u003E","return_module":"Contacts","return_action":"ListView","return_id":""}});\' class=\'\'>',
189
-					  'EMAIL_AND_NAME1' => 'first last &lt;&gt;',
190
-					);
191
-
192
-		$actual = $contact->get_list_view_data();
193
-		//$this->assertSame($expected, $actual);
194
-		$this->assertEquals($expected['NAME'], $actual['NAME']);
195
-		$this->assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']);
196
-		$this->assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']);
197
-		$this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']);
198
-		$this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']);
199
-		$this->assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']);
200
-
201
-	}
202
-
203
-
204
-	public function testbuild_generic_where_clause ()
205
-	{
174
+        //test with attributes preset and verify attributes are set accordingly
175
+        $contact->first_name = "first";
176
+        $contact->last_name = "last";
206 177
 
207
-		$contact = new Contact();
178
+        $expected = array (
179
+                        'NAME' => 'first last',
180
+                        'DELETED' => 0,
181
+                        'FIRST_NAME' => 'first',
182
+                        'LAST_NAME' => 'last',
183
+                        'FULL_NAME' => 'first last',
184
+                        'DO_NOT_CALL' => '0',
185
+                        'PORTAL_USER_TYPE' => 'Single user',
186
+                        'ENCODED_NAME' => 'first last',
187
+                        'EMAIL1' => '',
188
+                        'EMAIL1_LINK' => '<a href=\'javascript:void(0);\' onclick=\'SUGAR.quickCompose.init({"fullComposeUrl":"contact_id=\\u0026parent_type=Contacts\\u0026parent_id=\\u0026parent_name=first+last\\u0026to_addrs_ids=\\u0026to_addrs_names=first+last\\u0026to_addrs_emails=\\u0026to_email_addrs=first+last%26nbsp%3B%26lt%3B%26gt%3B\\u0026return_module=Contacts\\u0026return_action=ListView\\u0026return_id=","composePackage":{"contact_id":"","parent_type":"Contacts","parent_id":"","parent_name":"first last","to_addrs_ids":"","to_addrs_names":"first last","to_addrs_emails":"","to_email_addrs":"first last \\u003C\\u003E","return_module":"Contacts","return_action":"ListView","return_id":""}});\' class=\'\'>',
189
+                        'EMAIL_AND_NAME1' => 'first last &lt;&gt;',
190
+                    );
208 191
 
209
-		//test with string
210
-		$expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'";
211
-		$actual = $contact->build_generic_where_clause('test');
212
-		$this->assertSame($expected,$actual);
192
+        $actual = $contact->get_list_view_data();
193
+        //$this->assertSame($expected, $actual);
194
+        $this->assertEquals($expected['NAME'], $actual['NAME']);
195
+        $this->assertEquals($expected['FIRST_NAME'], $actual['FIRST_NAME']);
196
+        $this->assertEquals($expected['LAST_NAME'], $actual['LAST_NAME']);
197
+        $this->assertEquals($expected['FULL_NAME'], $actual['FULL_NAME']);
198
+        $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']);
199
+        $this->assertEquals($expected['EMAIL_AND_NAME1'], $actual['EMAIL_AND_NAME1']);
213 200
 
201
+    }
214 202
 
215
-		//test with number
216
-		$expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'";
217
-		$actual = $contact->build_generic_where_clause(1);
218
-		$this->assertSame($expected,$actual);
219 203
 
220
-	}
204
+    public function testbuild_generic_where_clause ()
205
+    {
221 206
 
222
-	public function testset_notification_body()
223
-	{
224
-		$contact = new Contact();
207
+        $contact = new Contact();
225 208
 
226
-		//test with attributes preset and verify attributes are set accordingly
227
-		$contact->first_name = "first";
228
-		$contact->last_name = "last";
229
-		$contact->description = "some text";
230
-		$contact->fill_in_additional_list_fields();
209
+        //test with string
210
+        $expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'";
211
+        $actual = $contact->build_generic_where_clause('test');
212
+        $this->assertSame($expected,$actual);
231 213
 
232
-		$result = $contact->set_notification_body(new Sugar_Smarty(), $contact);
233 214
 
234
-		$this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']);
235
-		$this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']);
215
+        //test with number
216
+        $expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'";
217
+        $actual = $contact->build_generic_where_clause(1);
218
+        $this->assertSame($expected,$actual);
236 219
 
237
-	}
220
+    }
238 221
 
239
-	public function testget_contact_id_by_email()
240
-	{
241
-		$contact = new Contact();
222
+    public function testset_notification_body()
223
+    {
224
+        $contact = new Contact();
242 225
 
243
-		$result = $contact->get_contact_id_by_email("");
244
-		$this->assertEquals(null,$result);
226
+        //test with attributes preset and verify attributes are set accordingly
227
+        $contact->first_name = "first";
228
+        $contact->last_name = "last";
229
+        $contact->description = "some text";
230
+        $contact->fill_in_additional_list_fields();
245 231
 
232
+        $result = $contact->set_notification_body(new Sugar_Smarty(), $contact);
246 233
 
247
-		//$result = $contact->get_contact_id_by_email("[email protected]");
248
-		//$this->assertEquals(null,$result);
234
+        $this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']);
235
+        $this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']);
249 236
 
250
-		$this->markTestSkipped('Invalid Columns(email1,email2) in Query ');
237
+    }
251 238
 
252
-	}
239
+    public function testget_contact_id_by_email()
240
+    {
241
+        $contact = new Contact();
253 242
 
254
-	public function testsave_relationship_changes() {
243
+        $result = $contact->get_contact_id_by_email("");
244
+        $this->assertEquals(null,$result);
255 245
 
256
-		$contact = new Contact();
257 246
 
258
-		//execute the method and test if it works and does not throws an exception.
259
-		try {
260
-			$contact->save_relationship_changes(true);
261
-			$contact->save_relationship_changes(false);
262
-			$this->assertTrue(true);
263
-		}
264
-		catch (Exception $e) {
265
-			$this->fail();
266
-		}
247
+        //$result = $contact->get_contact_id_by_email("[email protected]");
248
+        //$this->assertEquals(null,$result);
267 249
 
268
-	}
250
+        $this->markTestSkipped('Invalid Columns(email1,email2) in Query ');
269 251
 
270
-	public function testbean_implements()
271
-	{
272
-		$contact = new Contact();
273
-		$this->assertEquals(false, $contact->bean_implements('')); //test with blank value
274
-		$this->assertEquals(false, $contact->bean_implements('test')); //test with invalid value
275
-		$this->assertEquals(true, $contact->bean_implements('ACL')); //test with valid value
276
-	}
252
+    }
277 253
 
278
-	public function testget_unlinked_email_query()
279
-	{
280
-		$contact = new Contact();
254
+    public function testsave_relationship_changes() {
281 255
 
282
-		//execute the method and verify that it retunrs expected results
283
-		$expected = "SELECT emails.id FROM emails  JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n	join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n	eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n	where eear.deleted=0 and eear.email_id not in\n	(select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n	) derivedemails on derivedemails.email_id = emails.id";
284
-		$actual = $contact->get_unlinked_email_query();
285
-		$this->assertSame($expected,$actual);
256
+        $contact = new Contact();
257
+
258
+        //execute the method and test if it works and does not throws an exception.
259
+        try {
260
+            $contact->save_relationship_changes(true);
261
+            $contact->save_relationship_changes(false);
262
+            $this->assertTrue(true);
263
+        }
264
+        catch (Exception $e) {
265
+            $this->fail();
266
+        }
267
+
268
+    }
269
+
270
+    public function testbean_implements()
271
+    {
272
+        $contact = new Contact();
273
+        $this->assertEquals(false, $contact->bean_implements('')); //test with blank value
274
+        $this->assertEquals(false, $contact->bean_implements('test')); //test with invalid value
275
+        $this->assertEquals(true, $contact->bean_implements('ACL')); //test with valid value
276
+    }
277
+
278
+    public function testget_unlinked_email_query()
279
+    {
280
+        $contact = new Contact();
281
+
282
+        //execute the method and verify that it retunrs expected results
283
+        $expected = "SELECT emails.id FROM emails  JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n	join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n	eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n	where eear.deleted=0 and eear.email_id not in\n	(select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n	) derivedemails on derivedemails.email_id = emails.id";
284
+        $actual = $contact->get_unlinked_email_query();
285
+        $this->assertSame($expected,$actual);
286 286
 
287
-	}
287
+    }
288 288
 
289 289
 
290 290
     public function testprocess_sync_to_outlook()
291 291
     {
292
-    	$contact = new Contact();
292
+        $contact = new Contact();
293 293
 
294
-    	//execute the method and test if it works and does not throws an exception.
295
-    	try {
296
-   			$contact->process_sync_to_outlook("all");
297
-    		$this->assertTrue(true);
298
-    	}
299
-    	catch (Exception $e) {
300
-    		$this->fail();
301
-    	}
294
+        //execute the method and test if it works and does not throws an exception.
295
+        try {
296
+                $contact->process_sync_to_outlook("all");
297
+            $this->assertTrue(true);
298
+        }
299
+        catch (Exception $e) {
300
+            $this->fail();
301
+        }
302 302
 
303 303
 
304
-    	//execute the method and test if it works and does not throws an exception.
305
-    	try {
306
-    		$contact->process_sync_to_outlook("1");
307
-    		$this->assertTrue(true);
308
-    	}
309
-    	catch (Exception $e) {
310
-    		$this->fail();
311
-    	}
304
+        //execute the method and test if it works and does not throws an exception.
305
+        try {
306
+            $contact->process_sync_to_outlook("1");
307
+            $this->assertTrue(true);
308
+        }
309
+        catch (Exception $e) {
310
+            $this->fail();
311
+        }
312 312
 
313 313
 
314 314
 
315
-	}
315
+    }
316 316
 
317 317
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@  discard block
 block discarded – undo
6 6
 
7 7
 		//execute the contructor and check for the Object type and  attributes
8 8
 		$contact = new Contact();
9
-		$this->assertInstanceOf('Contact',$contact);
10
-		$this->assertInstanceOf('Person',$contact);
11
-		$this->assertInstanceOf('SugarBean',$contact);
9
+		$this->assertInstanceOf('Contact', $contact);
10
+		$this->assertInstanceOf('Person', $contact);
11
+		$this->assertInstanceOf('SugarBean', $contact);
12 12
 
13 13
 		$this->assertAttributeEquals('Contacts', 'module_dir', $contact);
14 14
 		$this->assertAttributeEquals('Contact', 'object_name', $contact);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		//test with empty strings
30 30
 		$query = "";
31 31
 		$contact->add_list_count_joins($query, '');
32
-		$this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
32
+		$this->assertEquals(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query);
33 33
 
34 34
 
35 35
 		//test with valid string
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 		$expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n                    LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
38 38
 		$contact->add_list_count_joins($query, 'accounts.name');
39 39
 		$query = preg_replace('/\s+/', '', $query);
40
-		$expected =preg_replace('/\s+/', '', $expected);
41
-		$this->assertSame($expected,$query);
40
+		$expected = preg_replace('/\s+/', '', $expected);
41
+		$this->assertSame($expected, $query);
42 42
 		
43 43
 		//test with valid string
44 44
 		$query = "";
45 45
 		$expected = "\n	            LEFT JOIN accounts_contacts\n	            ON contacts.id=accounts_contacts.contact_id\n	            LEFT JOIN accounts\n	            ON accounts_contacts.account_id=accounts.id\n	                 LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ";
46 46
 		$contact->add_list_count_joins($query, 'contacts.name');
47
-		$this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ",$query);
47
+		$this->assertSame(" LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c ", $query);
48 48
 
49 49
 
50 50
 	}
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	{
54 54
 		$contact = new Contact();
55 55
 
56
-		$expected = array( "MAIN"=>"a", "ACCOUNT"=>"a");
56
+		$expected = array("MAIN"=>"a", "ACCOUNT"=>"a");
57 57
 		$actual = $contact->listviewACLHelper();
58
-		$this->assertSame($expected,$actual);
58
+		$this->assertSame($expected, $actual);
59 59
 
60 60
 	}
61 61
 
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
 		//test with empty string params
91 91
 		$expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where  contacts.deleted=0 ";
92
-		$actual = $contact->address_popup_create_new_list_query('','');
93
-		$this->assertSame($expected,$actual);
92
+		$actual = $contact->address_popup_create_new_list_query('', '');
93
+		$this->assertSame($expected, $actual);
94 94
 
95 95
 
96 96
 		//test with valid string params
97 97
 		$expected = "SELECT LTRIM(RTRIM(CONCAT(IFNULL(contacts.first_name,''),'',IFNULL(contacts.last_name,'')))) name, \n				contacts.*,\n                accounts.name as account_name,\n                accounts.id as account_id,\n                accounts.assigned_user_id account_id_owner,\n                users.user_name as assigned_user_name ,contacts_cstm.*\n                FROM contacts LEFT JOIN users\n	                    ON contacts.assigned_user_id=users.id\n	                    LEFT JOIN accounts_contacts\n	                    ON contacts.id=accounts_contacts.contact_id  and accounts_contacts.deleted = 0\n	                    LEFT JOIN accounts\n	                    ON accounts_contacts.account_id=accounts.id AND accounts.deleted=0 LEFT JOIN email_addr_bean_rel eabl  ON eabl.bean_id = contacts.id AND eabl.bean_module = 'Contacts' and eabl.primary_address = 1 and eabl.deleted=0 LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id)  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND  contacts.deleted=0 ";
98
-		$actual = $contact->address_popup_create_new_list_query('contacts.id','contacts.name=""');
99
-		$this->assertSame($expected,$actual);
98
+		$actual = $contact->address_popup_create_new_list_query('contacts.id', 'contacts.name=""');
99
+		$this->assertSame($expected, $actual);
100 100
 
101 101
 	}
102 102
 
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 
107 107
 		//test with empty string params
108 108
 		$expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
109
-		$actual = $contact->create_export_query('','');
110
-		$this->assertSame($expected,$actual);
109
+		$actual = $contact->create_export_query('', '');
110
+		$this->assertSame($expected, $actual);
111 111
 
112 112
 
113 113
 		//test with valid string params
114 114
 		$expected = "SELECT\n                                contacts.*,\n                                email_addresses.email_address email_address,\n                                '' email_addresses_non_primary, accounts.name as account_name,\n                                users.user_name as assigned_user_name ,contacts_cstm.jjwg_maps_lng_c,contacts_cstm.jjwg_maps_lat_c,contacts_cstm.jjwg_maps_geocode_status_c,contacts_cstm.jjwg_maps_address_c FROM contacts LEFT JOIN users\n	                                ON contacts.assigned_user_id=users.id LEFT JOIN accounts_contacts\n	                                ON ( contacts.id=accounts_contacts.contact_id and (accounts_contacts.deleted is null or accounts_contacts.deleted = 0))\n	                                LEFT JOIN accounts\n	                                ON accounts_contacts.account_id=accounts.id  LEFT JOIN  email_addr_bean_rel on contacts.id = email_addr_bean_rel.bean_id and email_addr_bean_rel.bean_module='Contacts' and email_addr_bean_rel.deleted=0 and email_addr_bean_rel.primary_address=1  LEFT JOIN email_addresses on email_addresses.id = email_addr_bean_rel.email_address_id  LEFT JOIN contacts_cstm ON contacts.id = contacts_cstm.id_c where (contacts.name=\"\") AND ( accounts.deleted IS NULL OR accounts.deleted=0 )\n                      AND contacts.deleted=0 ";
115
-		$actual = $contact->create_export_query('contacts.id','contacts.name=""');
116
-		$this->assertSame($expected,$actual);
115
+		$actual = $contact->create_export_query('contacts.id', 'contacts.name=""');
116
+		$this->assertSame($expected, $actual);
117 117
 
118 118
 	}
119 119
 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 
131 131
 		$contact->fill_in_additional_list_fields();
132 132
 
133
-		$this->assertEquals("firstn lastn",$contact->full_name);
134
-		$this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name1);
135
-		$this->assertEquals("firstn lastn &lt;[email protected]&gt;",$contact->email_and_name2);
133
+		$this->assertEquals("firstn lastn", $contact->full_name);
134
+		$this->assertEquals("firstn lastn &lt;[email protected]&gt;", $contact->email_and_name1);
135
+		$this->assertEquals("firstn lastn &lt;[email protected]&gt;", $contact->email_and_name2);
136 136
 
137 137
 	}
138 138
 
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 
146 146
 		$contact->fill_in_additional_detail_fields();
147 147
 
148
-		$this->assertEquals("",$contact->account_name);
149
-		$this->assertEquals("",$contact->account_id);
150
-		$this->assertEquals("",$contact->report_to_name);
148
+		$this->assertEquals("", $contact->account_name);
149
+		$this->assertEquals("", $contact->account_id);
150
+		$this->assertEquals("", $contact->report_to_name);
151 151
 
152 152
 	}
153 153
 
154 154
 
155
-	public function testload_contacts_users_relationship(){
155
+	public function testload_contacts_users_relationship() {
156 156
 
157 157
 		$contact = new Contact();
158 158
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		$contact->first_name = "first";
176 176
 		$contact->last_name = "last";
177 177
 
178
-		$expected = array (
178
+		$expected = array(
179 179
 					  'NAME' => 'first last',
180 180
 					  'DELETED' => 0,
181 181
 					  'FIRST_NAME' => 'first',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 
204
-	public function testbuild_generic_where_clause ()
204
+	public function testbuild_generic_where_clause()
205 205
 	{
206 206
 
207 207
 		$contact = new Contact();
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 		//test with string
210 210
 		$expected = "contacts.last_name like 'test%' or contacts.first_name like 'test%' or accounts.name like 'test%' or contacts.assistant like 'test%' or ea.email_address like 'test%'";
211 211
 		$actual = $contact->build_generic_where_clause('test');
212
-		$this->assertSame($expected,$actual);
212
+		$this->assertSame($expected, $actual);
213 213
 
214 214
 
215 215
 		//test with number
216 216
 		$expected = "contacts.last_name like '1%' or contacts.first_name like '1%' or accounts.name like '1%' or contacts.assistant like '1%' or ea.email_address like '1%' or contacts.phone_home like '%1%' or contacts.phone_mobile like '%1%' or contacts.phone_work like '%1%' or contacts.phone_other like '%1%' or contacts.phone_fax like '%1%' or contacts.assistant_phone like '%1%'";
217 217
 		$actual = $contact->build_generic_where_clause(1);
218
-		$this->assertSame($expected,$actual);
218
+		$this->assertSame($expected, $actual);
219 219
 
220 220
 	}
221 221
 
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 
232 232
 		$result = $contact->set_notification_body(new Sugar_Smarty(), $contact);
233 233
 
234
-		$this->assertEquals($contact->full_name ,$result->_tpl_vars['CONTACT_NAME']);
235
-		$this->assertEquals($contact->description ,$result->_tpl_vars['CONTACT_DESCRIPTION']);
234
+		$this->assertEquals($contact->full_name, $result->_tpl_vars['CONTACT_NAME']);
235
+		$this->assertEquals($contact->description, $result->_tpl_vars['CONTACT_DESCRIPTION']);
236 236
 
237 237
 	}
238 238
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		$contact = new Contact();
242 242
 
243 243
 		$result = $contact->get_contact_id_by_email("");
244
-		$this->assertEquals(null,$result);
244
+		$this->assertEquals(null, $result);
245 245
 
246 246
 
247 247
 		//$result = $contact->get_contact_id_by_email("[email protected]");
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		//execute the method and verify that it retunrs expected results
283 283
 		$expected = "SELECT emails.id FROM emails  JOIN (select DISTINCT email_id from emails_email_addr_rel eear\n\n	join email_addr_bean_rel eabr on eabr.bean_id ='' and eabr.bean_module = 'Contacts' and\n	eabr.email_address_id = eear.email_address_id and eabr.deleted=0\n	where eear.deleted=0 and eear.email_id not in\n	(select eb.email_id from emails_beans eb where eb.bean_module ='Contacts' and eb.bean_id = '')\n	) derivedemails on derivedemails.email_id = emails.id";
284 284
 		$actual = $contact->get_unlinked_email_query();
285
-		$this->assertSame($expected,$actual);
285
+		$this->assertSame($expected, $actual);
286 286
 
287 287
 	}
288 288
 
Please login to merge, or discard this patch.
include/Smarty/plugins/modifier.spacify.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 function smarty_modifier_spacify($string, $spacify_char = ' ')
23 23
 {
24 24
     return implode($spacify_char,
25
-                   preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
25
+                    preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
26 26
 }
27 27
 
28 28
 /* vim: set expandtab: */
Please login to merge, or discard this patch.
modules/AOR_Reports/metadata/searchdefs.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@
 block discarded – undo
22 22
  * @author SalesAgility <[email protected]>
23 23
  */
24 24
  
25
-  $searchdefs['AOR_Reports'] = array(
26
-					'templateMeta' => array(
27
-							'maxColumns' => '3',
28
-  							'maxColumnsBasic' => '4', 
25
+    $searchdefs['AOR_Reports'] = array(
26
+                    'templateMeta' => array(
27
+                            'maxColumns' => '3',
28
+                                'maxColumnsBasic' => '4', 
29 29
                             'widths' => array('label' => '10', 'field' => '30'),                 
30
-                           ),
30
+                            ),
31 31
                     'layout' => array(  					
32
-						'basic_search' => array(
33
-							'name', 
34
-							array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
35
-							),
36
-						'advanced_search' => array(
37
-							'name', 
38
-							array('name' => 'assigned_user_id', 'label' => 'LBL_ASSIGNED_TO', 'type' => 'enum', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
39
-						),
40
-					),
41
- 			   );
32
+                        'basic_search' => array(
33
+                            'name', 
34
+                            array('name'=>'current_user_only', 'label'=>'LBL_CURRENT_USER_FILTER', 'type'=>'bool'),
35
+                            ),
36
+                        'advanced_search' => array(
37
+                            'name', 
38
+                            array('name' => 'assigned_user_id', 'label' => 'LBL_ASSIGNED_TO', 'type' => 'enum', 'function' => array('name' => 'get_user_array', 'params' => array(false))),
39
+                        ),
40
+                    ),
41
+                );
42 42
 ?>
Please login to merge, or discard this patch.
modules/Reminders/Reminder.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,9 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $savedReminderIds = array();
107 107
         foreach ($remindersData as $reminderData) {
108
-            if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = '';
108
+            if (isset($_POST['isDuplicate']) && $_POST['isDuplicate']) {
109
+                $reminderData->id = '';
110
+            }
109 111
             $reminderBean = BeanFactory::getBean('Reminders', $reminderData->id);
110 112
             $reminderBean->popup = $reminderData->popup;
111 113
             $reminderBean->email = $reminderData->email;
@@ -379,7 +381,9 @@  discard block
 block discarded – undo
379 381
     {
380 382
         $ret = '';
381 383
         for ($i = 0; $i < strlen($timestr); $i++) {
382
-            if ($timestr[$i] != "'") $ret .= $timestr[$i];
384
+            if ($timestr[$i] != "'") {
385
+                $ret .= $timestr[$i];
386
+            }
383 387
         }
384 388
         return $ret;
385 389
     }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         if (!empty($reminderBeans)) {
243 243
             foreach ($reminderBeans as $reminderBean) {
244 244
                 $eventBean = BeanFactory::getBean($reminderBean->related_event_module, $reminderBean->related_event_module_id);
245
-                if($eventBean) {
245
+                if ($eventBean) {
246 246
                     $remind_ts = $timedate->fromUser($eventBean->date_start)->modify("-{$reminderBean->timer_email} seconds")->ts;
247 247
                     $now_ts = $timedate->getNow()->ts;
248 248
                     if ($now_ts >= $remind_ts) {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                             $timeRemind = $popupReminder->timer_popup;
326 326
                             $timeStart -= $timeRemind;
327 327
 
328
-                            $url = 'index.php?action=DetailView&module=' . $popupReminder->related_event_module . '&record=' . $popupReminder->related_event_module_id;
328
+                            $url = 'index.php?action=DetailView&module='.$popupReminder->related_event_module.'&record='.$popupReminder->related_event_module_id;
329 329
                             $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG'];
330 330
 
331 331
                             if ($popupReminder->related_event_module == 'Meetings') {
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 
346 346
                             $relatedToMeeting = $alert->getRelatedName($popupReminder->related_event_module, $popupReminder->related_event_module_id);
347 347
 
348
-                            $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'] . $desc1 . "\n";
349
-                            $description = $description . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'] . (isset($relatedEvent->status) ? $relatedEvent->status : '') . "\n" . $app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'] . $relatedToMeeting;
348
+                            $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n";
349
+                            $description = $description."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'].(isset($relatedEvent->status) ? $relatedEvent->status : '')."\n".$app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO'].$relatedToMeeting;
350 350
 
351 351
 
352 352
                             if (isset($relatedEvent->date_start)) {
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 
365 365
                             // standard functionality
366 366
                             $alert->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName,
367
-                                $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'] . $time,
368
-                                $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'] . $location .
369
-                                $description .
367
+                                $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$time,
368
+                                $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$location.
369
+                                $description.
370 370
                                 $instructions,
371 371
                                 $timeStart - strtotime($alertDateTimeNow),
372 372
                                 $url
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
     private function upgradeEventPersonQuery(SugarBean $event, $person_table)
431 431
     {
432
-        $eventIdField = strtolower($event->object_name) . '_id';
432
+        $eventIdField = strtolower($event->object_name).'_id';
433 433
         $query = "
434 434
 			SELECT * FROM {$event->table_name}_{$person_table}
435 435
 			WHERE
@@ -443,9 +443,9 @@  discard block
 block discarded – undo
443 443
     {
444 444
         $eventIdField = array_search($event->table_name, $event->relationship_fields);
445 445
         if (!$eventIdField) {
446
-            $eventIdField = strtolower($event->object_name . '_id');
446
+            $eventIdField = strtolower($event->object_name.'_id');
447 447
         }
448
-        $personIdField = strtolower($person->object_name) . '_id';
448
+        $personIdField = strtolower($person->object_name).'_id';
449 449
         $query = "
450 450
 			SELECT * FROM {$event->table_name}_{$person->table_name}
451 451
 			WHERE
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
         }
533 533
     }
534 534
 
535
-	/**
536
-	 * @param string $eventModule 'Calls' or 'Meetings'
537
-	 */
535
+    /**
536
+     * @param string $eventModule 'Calls' or 'Meetings'
537
+     */
538 538
     private static function upgradeEventReminders($eventModule)
539 539
     {
540 540
         global $db;
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         $eventBean = BeanFactory::getBean($eventModule);
543 543
         $events = $eventBean->get_full_list('', "{$eventBean->table_name}.date_start >  {$db->convert('', 'today')} AND ({$eventBean->table_name}.reminder_time != -1 OR ({$eventBean->table_name}.email_reminder_time != -1 AND {$eventBean->table_name}.email_reminder_sent != 1))");
544 544
         if ($events) {
545
-			foreach ($events as $event) {
545
+            foreach ($events as $event) {
546 546
 
547 547
                 $oldReminderPopupChecked = false;
548 548
                 $oldReminderPopupTimer = null;
Please login to merge, or discard this patch.