1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class MeetingTest extends PHPUnit_Framework_TestCase { |
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
public function testMeeting() { |
7
|
|
|
|
8
|
|
|
error_reporting(E_ERROR | E_PARSE); |
9
|
|
|
|
10
|
|
|
//execute the contructor and check for the Object type and attributes |
11
|
|
|
$meeting = new Meeting(); |
12
|
|
|
|
13
|
|
|
$this->assertInstanceOf('Meeting',$meeting); |
14
|
|
|
$this->assertInstanceOf('SugarBean',$meeting); |
15
|
|
|
|
16
|
|
|
$this->assertAttributeEquals('Meetings', 'module_dir', $meeting); |
17
|
|
|
$this->assertAttributeEquals('Meeting', 'object_name', $meeting); |
18
|
|
|
$this->assertAttributeEquals('meetings', 'table_name', $meeting); |
19
|
|
|
|
20
|
|
|
$this->assertAttributeEquals(true, 'new_schema', $meeting); |
21
|
|
|
$this->assertAttributeEquals(true, 'importable', $meeting); |
22
|
|
|
$this->assertAttributeEquals(false, 'syncing', $meeting); |
23
|
|
|
$this->assertAttributeEquals(true, 'update_vcal', $meeting); |
24
|
|
|
|
25
|
|
|
$this->assertAttributeEquals('meetings_users', 'rel_users_table', $meeting); |
26
|
|
|
$this->assertAttributeEquals('meetings_contacts', 'rel_contacts_table', $meeting); |
27
|
|
|
$this->assertAttributeEquals('meetings_leads', 'rel_leads_table', $meeting); |
28
|
|
|
|
29
|
|
|
$this->assertAttributeEquals(null, 'cached_get_users', $meeting); |
30
|
|
|
$this->assertAttributeEquals(false, 'date_changed', $meeting); |
31
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testACLAccess(){ |
36
|
|
|
|
37
|
|
|
$meeting = new Meeting(); |
38
|
|
|
|
39
|
|
|
//test without recurring_source |
40
|
|
|
$this->assertEquals(true,$meeting->ACLAccess('edit')); |
41
|
|
|
$this->assertEquals(true,$meeting->ACLAccess('save')); |
42
|
|
|
$this->assertEquals(true,$meeting->ACLAccess('editview')); |
43
|
|
|
$this->assertEquals(true,$meeting->ACLAccess('delete')); |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
//test with recurring_source |
47
|
|
|
$meeting->recurring_source = "test"; |
48
|
|
|
$this->assertEquals(false,$meeting->ACLAccess('edit')); |
49
|
|
|
$this->assertEquals(false,$meeting->ACLAccess('save')); |
50
|
|
|
$this->assertEquals(false,$meeting->ACLAccess('editview')); |
51
|
|
|
$this->assertEquals(false,$meeting->ACLAccess('delete')); |
52
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
public function testhasIntegratedMeeting() { |
57
|
|
|
|
58
|
|
|
$meeting = new Meeting(); |
59
|
|
|
$result = $meeting->hasIntegratedMeeting(); |
60
|
|
|
$this->assertEquals(false, $result); |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
public function testSaveAndMarkdeletedAndSetAcceptStatus() { |
66
|
|
|
|
67
|
|
|
|
68
|
|
|
$meeting = new Meeting(); |
69
|
|
|
|
70
|
|
|
$meeting->name = "test"; |
71
|
|
|
$meeting->status = "Not Held"; |
72
|
|
|
$meeting->type = "Sugar"; |
73
|
|
|
$meeting->description = "test description"; |
74
|
|
|
$meeting->duration_hours = 1 ; |
75
|
|
|
$meeting->duration_minutes = 1; |
76
|
|
|
$meeting->date_start = "2016-02-11 17:30:00"; |
77
|
|
|
$meeting->date_end = "2016-02-11 17:30:00"; |
78
|
|
|
|
79
|
|
|
$meeting->save(); |
80
|
|
|
|
81
|
|
|
//test for record ID to verify that record is saved |
82
|
|
|
$this->assertTrue(isset($meeting->id)); |
83
|
|
|
$this->assertEquals(36, strlen($meeting->id)); |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
/* Test set_accept_status method */ |
87
|
|
|
|
88
|
|
|
//test set_accept_status with User object |
89
|
|
|
$user = new User(); |
90
|
|
|
$meeting->set_accept_status($user,"accept"); |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
//test set_accept_status with contact object |
94
|
|
|
$contact = new Contact(); |
95
|
|
|
$meeting->set_accept_status($contact,"accept"); |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
//test set_accept_status with Lead object |
99
|
|
|
$lead = new Lead(); |
100
|
|
|
$meeting->set_accept_status($lead,"accept"); |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
//mark all created relationships as deleted |
104
|
|
|
$meeting->mark_relationships_deleted($meeting->id); |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
//mark the record as deleted and verify that this record cannot be retrieved anymore. |
108
|
|
|
$meeting->mark_deleted($meeting->id); |
109
|
|
|
$result = $meeting->retrieve($meeting->id); |
110
|
|
|
$this->assertEquals(null,$result); |
111
|
|
|
|
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
public function testget_summary_text() { |
116
|
|
|
|
117
|
|
|
$meeting = new Meeting(); |
118
|
|
|
|
119
|
|
|
//test without setting name |
120
|
|
|
$this->assertEquals(Null,$meeting->get_summary_text()); |
121
|
|
|
|
122
|
|
|
//test with name set |
123
|
|
|
$meeting->name = "test"; |
124
|
|
|
$this->assertEquals('test',$meeting->get_summary_text()); |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
public function testcreate_export_query(){ |
130
|
|
|
|
131
|
|
|
$meeting = new Meeting(); |
132
|
|
|
|
133
|
|
|
//test with empty string params |
134
|
|
|
$expected = "SELECT meetings.*, users.user_name as assigned_user_name FROM meetings LEFT JOIN users ON meetings.assigned_user_id=users.id where meetings.deleted=0"; |
135
|
|
|
$actual = $meeting->create_export_query('',''); |
136
|
|
|
$this->assertSame($expected,$actual); |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
//test with valid string params |
140
|
|
|
$expected = "SELECT meetings.*, users.user_name as assigned_user_name FROM meetings LEFT JOIN users ON meetings.assigned_user_id=users.id where users.user_name=\"\" AND meetings.deleted=0"; |
141
|
|
|
$actual = $meeting->create_export_query('meetings.id','users.user_name=""'); |
142
|
|
|
$this->assertSame($expected,$actual); |
143
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function testfill_in_additional_detail_fields() { |
147
|
|
|
|
148
|
|
|
$meeting = new Meeting(); |
149
|
|
|
|
150
|
|
|
//preset required attributes |
151
|
|
|
$meeting->assigned_user_id =1; |
152
|
|
|
$meeting->modified_user_id =1; |
153
|
|
|
$meeting->created_by =1; |
154
|
|
|
$meeting->contact_id =1; |
155
|
|
|
|
156
|
|
|
$meeting->fill_in_additional_detail_fields(); |
157
|
|
|
|
158
|
|
|
//verify effected atributes |
159
|
|
|
$this->assertEquals("Administrator", $meeting->assigned_user_name); |
160
|
|
|
$this->assertEquals("Administrator", $meeting->created_by_name); |
161
|
|
|
$this->assertEquals("Administrator", $meeting->modified_by_name); |
162
|
|
|
$this->assertTrue(isset($meeting->time_start_hour)); |
163
|
|
|
$this->assertTrue(isset($meeting->date_start)); |
164
|
|
|
$this->assertTrue(isset($meeting->time_start)); |
165
|
|
|
$this->assertTrue(isset($meeting->duration_hours)); |
166
|
|
|
$this->assertTrue(isset($meeting->duration_minutes)); |
167
|
|
|
$this->assertEquals(-1, $meeting->reminder_time ); |
168
|
|
|
$this->assertTrue(isset($meeting->reminder_time)); |
169
|
|
|
$this->assertEquals(false, $meeting->reminder_checked ); |
170
|
|
|
$this->assertEquals(-1, $meeting->email_reminder_time ); |
171
|
|
|
$this->assertEquals(false, $meeting->email_reminder_checked ); |
172
|
|
|
$this->assertEquals("Accounts", $meeting->parent_type); |
173
|
|
|
|
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
public function testget_list_view_data() { |
177
|
|
|
|
178
|
|
|
$meeting = new Meeting(); |
179
|
|
|
|
180
|
|
|
//preset required attribute values |
181
|
|
|
$meeting->status == "Planned"; |
182
|
|
|
$meeting->parent_type = "Accounts"; |
183
|
|
|
$meeting->contact_id = 1; |
184
|
|
|
$meeting->contact_name = "test"; |
185
|
|
|
$meeting->parent_name = "Account"; |
186
|
|
|
|
187
|
|
|
$expected = array ( |
188
|
|
|
'DELETED' => 0, |
189
|
|
|
'PARENT_TYPE' => 'Accounts', |
190
|
|
|
'STATUS' => 'Planned', |
191
|
|
|
'TYPE' => 'Sugar', |
192
|
|
|
'REMINDER_TIME' => '-1', |
193
|
|
|
'EMAIL_REMINDER_TIME' => '-1', |
194
|
|
|
'EMAIL_REMINDER_SENT' => '0', |
195
|
|
|
'SEQUENCE' => '0', |
196
|
|
|
'CONTACT_NAME' => 'test', |
197
|
|
|
'PARENT_NAME' => '', |
198
|
|
|
'CONTACT_ID' => 1, |
199
|
|
|
'REPEAT_INTERVAL' => '1', |
200
|
|
|
'PARENT_MODULE' => 'Accounts', |
201
|
|
|
'SET_COMPLETE' => '<a id=\'\' onclick=\'SUGAR.util.closeActivityPanel.show("Meetings","","Held","listview","1");\'><img src="themes/SuiteR/images/close_inline.png?v=fqXdFZ_r6FC1K7P_Fy3mVw" border=\'0\' alt="Close" /></a>', |
202
|
|
|
'DATE_START' => '<font class=\'overdueTask\'></font>', |
203
|
|
|
'REMINDER_CHECKED' => false, |
204
|
|
|
'EMAIL_REMINDER_CHECKED' => false, |
205
|
|
|
); |
206
|
|
|
|
207
|
|
|
$actual = $meeting->get_list_view_data(); |
208
|
|
|
|
209
|
|
|
//$this->assertSame($expected, $actual); |
|
|
|
|
210
|
|
|
$this->assertEquals($expected['PARENT_TYPE'], $actual['PARENT_TYPE']); |
211
|
|
|
$this->assertEquals($expected['STATUS'], $actual['STATUS']); |
212
|
|
|
$this->assertEquals($expected['TYPE'], $actual['TYPE']); |
213
|
|
|
$this->assertEquals($expected['REMINDER_TIME'], $actual['REMINDER_TIME']); |
214
|
|
|
$this->assertEquals($expected['EMAIL_REMINDER_TIME'], $actual['EMAIL_REMINDER_TIME']); |
215
|
|
|
$this->assertEquals($expected['EMAIL_REMINDER_SENT'], $actual['EMAIL_REMINDER_SENT']); |
216
|
|
|
$this->assertEquals($expected['CONTACT_NAME'], $actual['CONTACT_NAME']); |
217
|
|
|
$this->assertEquals($expected['CONTACT_ID'], $actual['CONTACT_ID']); |
218
|
|
|
$this->assertEquals($expected['REPEAT_INTERVAL'], $actual['REPEAT_INTERVAL']); |
219
|
|
|
$this->assertEquals($expected['PARENT_MODULE'], $actual['PARENT_MODULE']); |
220
|
|
|
|
221
|
|
|
|
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function testset_notification_body() { |
225
|
|
|
|
226
|
|
|
global $current_user; |
227
|
|
|
$current_user = new User(1); |
228
|
|
|
|
229
|
|
|
$meeting = new Meeting(); |
230
|
|
|
|
231
|
|
|
//test with attributes preset and verify template variables are set accordingly |
232
|
|
|
$meeting->name = "test"; |
233
|
|
|
$meeting->status = "Not Held"; |
234
|
|
|
$meeting->type = "Sugar"; |
235
|
|
|
$meeting->description = "test description"; |
236
|
|
|
$meeting->duration_hours = 1 ; |
237
|
|
|
$meeting->duration_minutes = 1; |
238
|
|
|
$meeting->date_start = "2016-02-11 17:30:00"; |
239
|
|
|
$meeting->date_end = "2016-02-11 17:30:00"; |
240
|
|
|
|
241
|
|
|
$result = $meeting->set_notification_body(new Sugar_Smarty(), $meeting); |
242
|
|
|
|
243
|
|
|
$this->assertEquals($meeting->name ,$result->_tpl_vars['MEETING_SUBJECT']); |
244
|
|
|
$this->assertEquals($meeting->status ,$result->_tpl_vars['MEETING_STATUS']); |
245
|
|
|
$this->assertEquals("SuiteCRM" ,$result->_tpl_vars['MEETING_TYPE']); |
246
|
|
|
$this->assertEquals($meeting->duration_hours ,$result->_tpl_vars['MEETING_HOURS']); |
247
|
|
|
$this->assertEquals($meeting->duration_minutes ,$result->_tpl_vars['MEETING_MINUTES']); |
248
|
|
|
$this->assertEquals($meeting->description ,$result->_tpl_vars['MEETING_DESCRIPTION']); |
249
|
|
|
|
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
|
253
|
|
|
public function testcreate_notification_email(){ |
254
|
|
|
|
255
|
|
|
$meeting = new Meeting(); |
256
|
|
|
|
257
|
|
|
$meeting->date_start = "2016-02-11 17:30:00"; |
258
|
|
|
$meeting->date_end = "2016-02-11 17:30:00"; |
259
|
|
|
|
260
|
|
|
//test without setting user |
261
|
|
|
$result = $meeting->create_notification_email(new User()); |
262
|
|
|
$this->assertInstanceOf('SugarPHPMailer', $result); |
263
|
|
|
|
264
|
|
|
//test with valid user |
265
|
|
|
$result = $meeting->create_notification_email(new User(1)); |
266
|
|
|
$this->assertInstanceOf('SugarPHPMailer', $result); |
267
|
|
|
|
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
|
271
|
|
|
public function testsend_assignment_notifications(){ |
272
|
|
|
|
273
|
|
|
$meeting = new Meeting(); |
274
|
|
|
|
275
|
|
|
$meeting->date_start = "2016-02-11 17:30:00"; |
276
|
|
|
$meeting->date_end = "2016-02-11 17:30:00"; |
277
|
|
|
|
278
|
|
|
$admin = new Administration(); |
279
|
|
|
$admin->retrieveSettings(); |
280
|
|
|
$sendNotifications = false; |
|
|
|
|
281
|
|
|
|
282
|
|
|
$notify_user = new User(1); |
283
|
|
|
|
284
|
|
|
|
285
|
|
|
//execute the method and test if it works and does not throws an exception. |
286
|
|
|
try { |
287
|
|
|
$meeting->send_assignment_notifications($notify_user, $admin); |
288
|
|
|
$this->assertTrue(true); |
289
|
|
|
} |
290
|
|
|
catch (Exception $e) { |
291
|
|
|
$this->fail(); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function testget_meeting_users() { |
297
|
|
|
|
298
|
|
|
$meeting = new Meeting(); |
299
|
|
|
|
300
|
|
|
$result = $meeting->get_meeting_users(); |
301
|
|
|
$this->assertTrue(is_array($result)); |
302
|
|
|
|
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
public function testget_invite_meetings() { |
306
|
|
|
|
307
|
|
|
$meeting = new Meeting(); |
308
|
|
|
|
309
|
|
|
$result = $meeting->get_invite_meetings(new User()); |
310
|
|
|
$this->assertTrue(is_array($result)); |
311
|
|
|
|
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
|
315
|
|
|
public function testget_notification_recipients() { |
316
|
|
|
|
317
|
|
|
$meeting = new Meeting(); |
318
|
|
|
|
319
|
|
|
//test without special_notification |
320
|
|
|
$result = $meeting->get_notification_recipients(); |
321
|
|
|
$this->assertTrue(is_array($result)); |
322
|
|
|
|
323
|
|
|
|
324
|
|
|
//test with special_notification |
325
|
|
|
$meeting->special_notification = 1; |
|
|
|
|
326
|
|
|
$result = $meeting->get_notification_recipients(); |
327
|
|
|
$this->assertTrue(is_array($result)); |
328
|
|
|
|
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
|
332
|
|
|
public function testbean_implements() { |
333
|
|
|
|
334
|
|
|
$meeting = new Meeting(); |
335
|
|
|
|
336
|
|
|
$this->assertEquals(false, $meeting->bean_implements('')); //test with blank value |
337
|
|
|
$this->assertEquals(false, $meeting->bean_implements('test')); //test with invalid value |
338
|
|
|
$this->assertEquals(true, $meeting->bean_implements('ACL')); //test with valid value |
339
|
|
|
|
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
public function testlistviewACLHelper() { |
343
|
|
|
|
344
|
|
|
$meeting = new Meeting(); |
345
|
|
|
|
346
|
|
|
$expected = array("MAIN"=>"a", "PARENT"=>"a", "CONTACT"=>"a" ); |
347
|
|
|
$actual = $meeting->listviewACLHelper(); |
348
|
|
|
$this->assertSame($expected,$actual); |
349
|
|
|
|
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
|
353
|
|
|
public function testsave_relationship_changes() { |
354
|
|
|
|
355
|
|
|
$meeting = new Meeting(); |
356
|
|
|
|
357
|
|
|
//execute the method and test if it works and does not throws an exception. |
358
|
|
|
try { |
359
|
|
|
$meeting->save_relationship_changes(); |
360
|
|
|
$this->assertTrue(true); |
361
|
|
|
} |
362
|
|
|
catch (Exception $e) { |
363
|
|
|
$this->fail(); |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
|
367
|
|
|
} |
368
|
|
|
|
369
|
|
|
|
370
|
|
|
public function testafterImportSave(){ |
371
|
|
|
|
372
|
|
|
require_once("data/Link.php"); |
373
|
|
|
|
374
|
|
|
$meeting = new Meeting(); |
375
|
|
|
|
376
|
|
|
//execute the method and test if it works and does not throws an exception. |
377
|
|
|
try { |
378
|
|
|
|
379
|
|
|
//test without parent_type |
380
|
|
|
$meeting->afterImportSave(); |
381
|
|
|
|
382
|
|
|
//test with parent_type Contacts |
383
|
|
|
$meeting->parent_type = 'Contacts'; |
384
|
|
|
$meeting->afterImportSave(); |
385
|
|
|
|
386
|
|
|
//test with parent_type Leads |
387
|
|
|
$meeting->parent_type = 'Leads'; |
388
|
|
|
$meeting->afterImportSave(); |
389
|
|
|
|
390
|
|
|
$this->assertTrue(true); |
391
|
|
|
|
392
|
|
|
} |
393
|
|
|
catch (Exception $e) { |
394
|
|
|
$this->fail(); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
|
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
public function testgetDefaultStatus(){ |
401
|
|
|
|
402
|
|
|
$meeting = new Meeting(); |
403
|
|
|
$result = $meeting->getDefaultStatus(); |
404
|
|
|
$this->assertEquals("Planned", $result); |
405
|
|
|
|
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
|
409
|
|
|
|
410
|
|
|
public function testgetMeetingsExternalApiDropDown(){ |
411
|
|
|
|
412
|
|
|
$actual = getMeetingsExternalApiDropDown(); |
413
|
|
|
$expected= array( "Sugar"=>"SuiteCRM"); |
414
|
|
|
$this->assertSame($expected, $actual); |
415
|
|
|
|
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
|
419
|
|
|
public function testgetMeetingTypeOptions(){ |
420
|
|
|
|
421
|
|
|
global $dictionary, $app_list_strings; |
422
|
|
|
|
423
|
|
|
$result = getMeetingTypeOptions($dictionary, $app_list_strings); |
424
|
|
|
$this->assertTrue(is_array($result)); |
425
|
|
|
|
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
|
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.