Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
3 | require_once 'CiviTest/Contact.php'; | |
aba1cd8b EM |
4 | |
5 | /** | |
6 | * Class CRM_Activity_BAO_ActivityTest | |
7 | */ | |
6a488035 | 8 | class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { |
00be9182 | 9 | public function setUp() { |
6a488035 TO |
10 | parent::setUp(); |
11 | } | |
12 | ||
00be9182 | 13 | public function tearDown() { |
6a488035 | 14 | // truncate a few tables |
b319d00a | 15 | $tablesToTruncate = array('civicrm_contact', 'civicrm_activity', 'civicrm_activity_contact'); |
6a488035 TO |
16 | $this->quickCleanup($tablesToTruncate); |
17 | } | |
18 | ||
19 | /** | |
fe482240 | 20 | * Test case for create() method. |
6a488035 | 21 | */ |
00be9182 | 22 | public function testCreate() { |
6a488035 TO |
23 | $contactId = Contact::createIndividual(); |
24 | ||
25 | $params = array( | |
26 | 'source_contact_id' => $contactId, | |
27 | 'subject' => 'Scheduling Meeting', | |
28 | 'activity_type_id' => 2, | |
29 | ); | |
30 | ||
31 | CRM_Activity_BAO_Activity::create($params); | |
32 | ||
33 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
34 | 'subject', 'Database check for created activity.' | |
35 | ); | |
36 | ||
37 | // Now call create() to modify an existing Activity | |
38 | ||
39 | $params = array(); | |
40 | $params = array( | |
41 | 'id' => $activityId, | |
42 | 'source_contact_id' => $contactId, | |
43 | 'subject' => 'Scheduling Interview', | |
44 | 'activity_type_id' => 3, | |
45 | ); | |
46 | ||
47 | CRM_Activity_BAO_Activity::create($params); | |
48 | ||
49 | $activityTypeId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Interview', | |
50 | 'activity_type_id', | |
51 | 'subject', 'Database check on updated activity record.' | |
52 | ); | |
53 | $this->assertEquals($activityTypeId, 3, 'Verify activity type id is 3.'); | |
54 | ||
55 | Contact::delete($contactId); | |
56 | } | |
57 | ||
58 | /** | |
fe482240 EM |
59 | * Test case for getContactActivity() method. |
60 | * | |
61 | * getContactActivity() method get activities detail for given target contact id. | |
6a488035 | 62 | */ |
00be9182 | 63 | public function testGetContactActivity() { |
6a488035 TO |
64 | $contactId = Contact::createIndividual(); |
65 | $params = array( | |
66 | 'first_name' => 'liz', | |
67 | 'last_name' => 'hurleey', | |
68 | ); | |
69 | $targetContactId = Contact::createIndividual($params); | |
70 | ||
71 | $params = array( | |
72 | 'source_contact_id' => $contactId, | |
73 | 'subject' => 'Scheduling Meeting', | |
74 | 'activity_type_id' => 2, | |
75 | 'target_contact_id' => array($targetContactId), | |
76 | 'activity_date_time' => date('Ymd'), | |
77 | ); | |
78 | ||
79 | CRM_Activity_BAO_Activity::create($params); | |
80 | ||
81 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', | |
82 | 'id', | |
83 | 'subject', 'Database check for created activity.' | |
84 | ); | |
85 | ||
86 | $activities = CRM_Activity_BAO_Activity::getContactActivity($targetContactId); | |
87 | ||
88 | $this->assertEquals($activities[$activityId]['subject'], 'Scheduling Meeting', 'Verify activity subject is correct.'); | |
89 | ||
90 | Contact::delete($contactId); | |
91 | Contact::delete($targetContactId); | |
92 | } | |
93 | ||
94 | /** | |
fe482240 EM |
95 | * Test case for retrieve() method. |
96 | * | |
97 | * Retrieve($params, $defaults) method return activity detail for given params | |
6a488035 TO |
98 | * and set defaults. |
99 | */ | |
00be9182 | 100 | public function testRetrieve() { |
6a488035 TO |
101 | $contactId = Contact::createIndividual(); |
102 | $params = array( | |
103 | 'first_name' => 'liz', | |
104 | 'last_name' => 'hurleey', | |
105 | ); | |
106 | $targetContactId = Contact::createIndividual($params); | |
107 | ||
108 | $params = array( | |
109 | 'source_contact_id' => $contactId, | |
110 | 'subject' => 'Scheduling Meeting', | |
111 | 'activity_type_id' => 2, | |
112 | 'target_contact_id' => array($targetContactId), | |
113 | 'activity_date_time' => date('Ymd'), | |
114 | ); | |
115 | ||
116 | CRM_Activity_BAO_Activity::create($params); | |
117 | ||
118 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
119 | 'subject', 'Database check for created activity.' | |
120 | ); | |
121 | ||
f1c7b1f0 DL |
122 | $activityTargetId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', $targetContactId, |
123 | 'id', 'contact_id', | |
6a488035 TO |
124 | 'Database check for created activity target.' |
125 | ); | |
126 | ||
127 | $defaults = array(); | |
128 | $activity = CRM_Activity_BAO_Activity::retrieve($params, $defaults); | |
129 | ||
130 | $this->assertEquals($activity->subject, 'Scheduling Meeting', 'Verify activity subject is correct.'); | |
6a488035 | 131 | $this->assertEquals($activity->activity_type_id, 2, 'Verify activity type id is correct.'); |
b2e56051 | 132 | $this->assertEquals($defaults['source_contact_id'], $contactId, 'Verify source contact id is correct.'); |
6a488035 TO |
133 | |
134 | $this->assertEquals($defaults['subject'], 'Scheduling Meeting', 'Verify activity subject is correct.'); | |
6a488035 TO |
135 | $this->assertEquals($defaults['activity_type_id'], 2, 'Verify activity type id is correct.'); |
136 | ||
137 | $this->assertEquals($defaults['target_contact'][0], $targetContactId, 'Verify target contact id is correct.'); | |
138 | ||
139 | Contact::delete($contactId); | |
140 | Contact::delete($targetContactId); | |
141 | } | |
142 | ||
143 | /** | |
fe482240 EM |
144 | * Test case for deleteActivity() method. |
145 | * | |
6a488035 TO |
146 | * deleteActivity($params) method deletes activity for given params. |
147 | */ | |
00be9182 | 148 | public function testDeleteActivity() { |
6a488035 TO |
149 | $contactId = Contact::createIndividual(); |
150 | $params = array( | |
151 | 'first_name' => 'liz', | |
152 | 'last_name' => 'hurleey', | |
153 | ); | |
154 | $targetContactId = Contact::createIndividual($params); | |
155 | ||
156 | $params = array( | |
157 | 'source_contact_id' => $contactId, | |
158 | 'source_record_id' => $contactId, | |
159 | 'subject' => 'Scheduling Meeting', | |
160 | 'activity_type_id' => 2, | |
161 | 'target_contact_id' => array($targetContactId), | |
162 | 'activity_date_time' => date('Ymd'), | |
163 | ); | |
164 | ||
165 | CRM_Activity_BAO_Activity::create($params); | |
166 | ||
167 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
168 | 'subject', 'Database check for created activity.' | |
169 | ); | |
170 | ||
f1c7b1f0 DL |
171 | $activityTargetId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', $targetContactId, |
172 | 'id', 'contact_id', | |
6a488035 TO |
173 | 'Database check for created activity target.' |
174 | ); | |
175 | $params = array( | |
176 | 'source_contact_id' => $contactId, | |
177 | 'source_record_id' => $contactId, | |
178 | 'subject' => 'Scheduling Meeting', | |
179 | 'activity_type_id' => 2, | |
180 | ); | |
181 | ||
182 | $result = CRM_Activity_BAO_Activity::deleteActivity($params); | |
183 | ||
184 | $activityId = $this->assertDBNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
185 | 'subject', 'Database check for deleted activity.' | |
186 | ); | |
187 | Contact::delete($contactId); | |
188 | Contact::delete($targetContactId); | |
189 | } | |
190 | ||
191 | /** | |
fe482240 EM |
192 | * Test case for deleteActivityTarget() method. |
193 | * | |
6a488035 TO |
194 | * deleteActivityTarget($activityId) method deletes activity target for given activity id. |
195 | */ | |
00be9182 | 196 | public function testDeleteActivityTarget() { |
6a488035 TO |
197 | $contactId = Contact::createIndividual(); |
198 | $params = array( | |
199 | 'first_name' => 'liz', | |
200 | 'last_name' => 'hurleey', | |
201 | ); | |
202 | $targetContactId = Contact::createIndividual($params); | |
203 | ||
204 | $params = array( | |
205 | 'source_contact_id' => $contactId, | |
206 | 'subject' => 'Scheduling Meeting', | |
207 | 'activity_type_id' => 2, | |
208 | 'target_contact_id' => array($targetContactId), | |
209 | 'activity_date_time' => date('Ymd'), | |
210 | ); | |
211 | ||
212 | CRM_Activity_BAO_Activity::create($params); | |
213 | ||
214 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
215 | 'subject', 'Database check for created activity.' | |
216 | ); | |
217 | ||
f1c7b1f0 DL |
218 | $activityTargetId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', $targetContactId, |
219 | 'id', 'contact_id', | |
6a488035 TO |
220 | 'Database check for created activity target.' |
221 | ); | |
222 | ||
2517d079 | 223 | CRM_Activity_BAO_Activity::deleteActivityContact($activityId, 3); |
6a488035 | 224 | |
f1c7b1f0 DL |
225 | $this->assertDBNull('CRM_Activity_DAO_ActivityContact', $targetContactId, 'id', |
226 | 'contact_id', 'Database check for deleted activity target.' | |
6a488035 TO |
227 | ); |
228 | ||
229 | Contact::delete($contactId); | |
230 | Contact::delete($targetContactId); | |
231 | } | |
232 | ||
233 | /** | |
fe482240 EM |
234 | * Test case for deleteActivityAssignment() method. |
235 | * | |
6a488035 TO |
236 | * deleteActivityAssignment($activityId) method deletes activity assignment for given activity id. |
237 | */ | |
00be9182 | 238 | public function testDeleteActivityAssignment() { |
6a488035 TO |
239 | $contactId = Contact::createIndividual(); |
240 | $params = array( | |
241 | 'first_name' => 'liz', | |
242 | 'last_name' => 'hurleey', | |
243 | ); | |
244 | $assigneeContactId = Contact::createIndividual($params); | |
245 | ||
246 | $params = array( | |
247 | 'source_contact_id' => $contactId, | |
248 | 'subject' => 'Scheduling Meeting', | |
249 | 'activity_type_id' => 2, | |
250 | 'assignee_contact_id' => array($assigneeContactId), | |
251 | 'activity_date_time' => date('Ymd'), | |
252 | ); | |
253 | ||
254 | CRM_Activity_BAO_Activity::create($params); | |
255 | ||
256 | $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', | |
257 | 'subject', 'Database check for created activity.' | |
258 | ); | |
259 | ||
f1c7b1f0 DL |
260 | $activityAssignmentId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', |
261 | $assigneeContactId, 'id', 'contact_id', | |
6a488035 TO |
262 | 'Database check for created activity assignment.' |
263 | ); | |
264 | ||
2517d079 | 265 | CRM_Activity_BAO_Activity::deleteActivityContact($activityId, 1); |
6a488035 | 266 | |
f1c7b1f0 DL |
267 | $this->assertDBNull('CRM_Activity_DAO_ActivityContact', $assigneeContactId, 'id', |
268 | 'contact_id', 'Database check for deleted activity assignment.' | |
6a488035 TO |
269 | ); |
270 | ||
271 | Contact::delete($contactId); | |
272 | Contact::delete($assigneeContactId); | |
273 | } | |
274 | ||
275 | /** | |
eceb18cc | 276 | * Test getActivitiesCount BAO method. |
6a488035 | 277 | */ |
00be9182 | 278 | public function testGetActivitiesCountforAdminDashboard() { |
6a488035 TO |
279 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
280 | $op->execute($this->_dbconn, | |
bbfd46a5 | 281 | $this->createFlatXMLDataSet( |
6a488035 TO |
282 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
283 | ) | |
284 | ); | |
285 | ||
286 | $params = array( | |
287 | 'contact_id' => NULL, | |
288 | 'admin' => TRUE, | |
289 | 'caseId' => NULL, | |
290 | 'context' => 'home', | |
291 | 'activity_type_id' => NULL, | |
292 | 'offset' => 0, | |
293 | 'rowCount' => 0, | |
294 | 'sort' => NULL, | |
295 | ); | |
296 | $activityCount = CRM_Activity_BAO_Activity::getActivitiesCount($params); | |
297 | ||
298 | //since we are loading activities from dataset, we know total number of activities | |
299 | // 8 schedule activities that should be shown on dashboard | |
300 | $count = 8; | |
a15773db | 301 | $this->assertEquals($count, $activityCount); |
6a488035 TO |
302 | } |
303 | ||
304 | /** | |
eceb18cc | 305 | * Test getActivitiesCount BAO method. |
6a488035 | 306 | */ |
00be9182 | 307 | public function testGetActivitiesCountforNonAdminDashboard() { |
6a488035 TO |
308 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
309 | $op->execute($this->_dbconn, | |
bbfd46a5 | 310 | $this->createFlatXMLDataSet( |
6a488035 TO |
311 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
312 | ) | |
313 | ); | |
314 | ||
315 | $params = array( | |
316 | 'contact_id' => 9, | |
317 | 'admin' => FALSE, | |
318 | 'caseId' => NULL, | |
319 | 'context' => 'home', | |
320 | 'activity_type_id' => NULL, | |
321 | 'offset' => 0, | |
322 | 'rowCount' => 0, | |
323 | 'sort' => NULL, | |
324 | ); | |
325 | ||
326 | $activityCount = CRM_Activity_BAO_Activity::getActivitiesCount($params); | |
327 | ||
328 | //since we are loading activities from dataset, we know total number of activities for this contact | |
329 | // 5 activities ( 2 scheduled, 3 Completed ), note that dashboard shows only scheduled activities | |
330 | $count = 2; | |
a15773db | 331 | $this->assertEquals($count, $activityCount); |
6a488035 TO |
332 | } |
333 | ||
334 | /** | |
eceb18cc | 335 | * Test getActivitiesCount BAO method. |
6a488035 | 336 | */ |
00be9182 | 337 | public function testGetActivitiesCountforContactSummary() { |
6a488035 TO |
338 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
339 | $op->execute($this->_dbconn, | |
bbfd46a5 | 340 | $this->createFlatXMLDataSet( |
6a488035 TO |
341 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
342 | ) | |
343 | ); | |
344 | ||
345 | $params = array( | |
346 | 'contact_id' => 9, | |
347 | 'admin' => FALSE, | |
348 | 'caseId' => NULL, | |
349 | 'context' => 'activity', | |
350 | 'activity_type_id' => NULL, | |
351 | 'offset' => 0, | |
352 | 'rowCount' => 0, | |
353 | 'sort' => NULL, | |
354 | ); | |
355 | $activityCount = CRM_Activity_BAO_Activity::getActivitiesCount($params); | |
356 | ||
357 | //since we are loading activities from dataset, we know total number of activities for this contact | |
358 | // 5 activities, Contact Summary should show all activities | |
359 | $count = 5; | |
a15773db | 360 | $this->assertEquals($count, $activityCount); |
6a488035 TO |
361 | } |
362 | ||
363 | /** | |
eceb18cc | 364 | * Test getActivitiesCount BAO method. |
6a488035 | 365 | */ |
00be9182 | 366 | public function testGetActivitiesCountforContactSummaryWithNoActivities() { |
6a488035 TO |
367 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
368 | $op->execute($this->_dbconn, | |
bbfd46a5 | 369 | $this->createFlatXMLDataSet( |
6a488035 TO |
370 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
371 | ) | |
372 | ); | |
373 | ||
374 | $params = array( | |
375 | 'contact_id' => 17, | |
376 | 'admin' => FALSE, | |
377 | 'caseId' => NULL, | |
378 | 'context' => 'home', | |
379 | 'activity_type_id' => NULL, | |
380 | 'offset' => 0, | |
381 | 'rowCount' => 0, | |
382 | 'sort' => NULL, | |
383 | ); | |
384 | $activityCount = CRM_Activity_BAO_Activity::getActivitiesCount($params); | |
385 | ||
386 | //since we are loading activities from dataset, we know total number of activities for this contact | |
387 | // this contact does not have any activity | |
a15773db | 388 | $this->assertEquals(0, $activityCount); |
6a488035 TO |
389 | } |
390 | ||
391 | /** | |
eceb18cc | 392 | * Test getActivities BAO method. |
6a488035 | 393 | */ |
00be9182 | 394 | public function testGetActivitiesforAdminDashboard() { |
6a488035 TO |
395 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
396 | $op->execute($this->_dbconn, | |
bbfd46a5 | 397 | $this->createFlatXMLDataSet( |
6a488035 TO |
398 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
399 | ) | |
400 | ); | |
401 | ||
402 | $params = array( | |
403 | 'contact_id' => 5, | |
404 | 'admin' => TRUE, | |
405 | 'caseId' => NULL, | |
406 | 'context' => 'home', | |
407 | 'activity_type_id' => NULL, | |
408 | 'offset' => 0, | |
409 | 'rowCount' => 0, | |
410 | 'sort' => NULL, | |
411 | ); | |
412 | $activities = CRM_Activity_BAO_Activity::getActivities($params); | |
413 | ||
414 | //since we are loading activities from dataset, we know total number of activities | |
415 | // 8 schedule activities that should be shown on dashboard | |
416 | $count = 8; | |
ba4a1892 | 417 | $this->assertEquals($count, count($activities)); |
6a488035 TO |
418 | |
419 | foreach ($activities as $key => $value) { | |
420 | $this->assertEquals($value['subject'], "subject {$key}", 'Verify activity subject is correct.'); | |
421 | $this->assertEquals($value['activity_type_id'], 2, 'Verify activity type is correct.'); | |
422 | $this->assertEquals($value['status_id'], 1, 'Verify all activities are scheduled.'); | |
423 | } | |
424 | } | |
425 | ||
426 | /** | |
eceb18cc | 427 | * Test getActivities BAO method. |
6a488035 | 428 | */ |
00be9182 | 429 | public function testGetActivitiesforNonAdminDashboard() { |
6a488035 TO |
430 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
431 | $op->execute($this->_dbconn, | |
bbfd46a5 | 432 | $this->createFlatXMLDataSet( |
6a488035 TO |
433 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
434 | ) | |
435 | ); | |
436 | ||
437 | $contactID = 9; | |
438 | $params = array( | |
439 | 'contact_id' => $contactID, | |
440 | 'admin' => FALSE, | |
441 | 'caseId' => NULL, | |
442 | 'context' => 'home', | |
443 | 'activity_type_id' => NULL, | |
444 | 'offset' => 0, | |
445 | 'rowCount' => 0, | |
446 | 'sort' => NULL, | |
447 | ); | |
448 | $activities = CRM_Activity_BAO_Activity::getActivities($params); | |
449 | ||
450 | //since we are loading activities from dataset, we know total number of activities for this contact | |
451 | // 5 activities ( 2 scheduled, 3 Completed ), note that dashboard shows only scheduled activities | |
452 | $count = 2; | |
ba4a1892 | 453 | $this->assertEquals($count, count($activities)); |
6a488035 TO |
454 | |
455 | foreach ($activities as $key => $value) { | |
456 | $this->assertEquals($value['subject'], "subject {$key}", 'Verify activity subject is correct.'); | |
457 | $this->assertEquals($value['activity_type_id'], 2, 'Verify activity type is correct.'); | |
458 | $this->assertEquals($value['status_id'], 1, 'Verify all activities are scheduled.'); | |
459 | ||
460 | if ($key == 3) { | |
461 | $this->assertArrayHasKey($contactID, $value['target_contact_name']); | |
462 | } | |
463 | elseif ($key == 4) { | |
464 | $this->assertArrayHasKey($contactID, $value['assignee_contact_name']); | |
465 | } | |
466 | } | |
467 | } | |
468 | ||
469 | /** | |
eceb18cc | 470 | * Test getActivities BAO method. |
6a488035 | 471 | */ |
00be9182 | 472 | public function testGetActivitiesforContactSummary() { |
6a488035 TO |
473 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
474 | $op->execute($this->_dbconn, | |
bbfd46a5 | 475 | $this->createFlatXMLDataSet( |
6a488035 TO |
476 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
477 | ) | |
478 | ); | |
479 | ||
480 | $contactID = 9; | |
481 | $params = array( | |
482 | 'contact_id' => $contactID, | |
483 | 'admin' => FALSE, | |
484 | 'caseId' => NULL, | |
485 | 'context' => 'activity', | |
486 | 'activity_type_id' => NULL, | |
487 | 'offset' => 0, | |
488 | 'rowCount' => 0, | |
489 | 'sort' => NULL, | |
490 | ); | |
491 | $activities = CRM_Activity_BAO_Activity::getActivities($params); | |
492 | ||
493 | //since we are loading activities from dataset, we know total number of activities for this contact | |
494 | // 5 activities, Contact Summary should show all activities | |
495 | $count = 5; | |
ba4a1892 | 496 | $this->assertEquals($count, count($activities)); |
6a488035 TO |
497 | |
498 | foreach ($activities as $key => $value) { | |
499 | $this->assertEquals($value['subject'], "subject {$key}", 'Verify activity subject is correct.'); | |
500 | ||
501 | if ($key > 8) { | |
502 | $this->assertEquals($value['status_id'], 2, 'Verify all activities are scheduled.'); | |
503 | } | |
504 | else { | |
505 | $this->assertEquals($value['status_id'], 1, 'Verify all activities are scheduled.'); | |
506 | } | |
507 | ||
508 | if ($key > 8) { | |
509 | $this->assertEquals($value['activity_type_id'], 1, 'Verify activity type is correct.'); | |
510 | } | |
511 | else { | |
512 | $this->assertEquals($value['activity_type_id'], 2, 'Verify activity type is correct.'); | |
513 | } | |
514 | ||
515 | if ($key == 3) { | |
516 | $this->assertArrayHasKey($contactID, $value['target_contact_name']); | |
517 | } | |
518 | elseif ($key == 4) { | |
519 | $this->assertArrayHasKey($contactID, $value['assignee_contact_name']); | |
520 | } | |
521 | } | |
522 | } | |
523 | ||
524 | /** | |
eceb18cc | 525 | * Test getActivities BAO method. |
6a488035 | 526 | */ |
00be9182 | 527 | public function testGetActivitiesforContactSummaryWithNoActivities() { |
6a488035 TO |
528 | $op = new PHPUnit_Extensions_Database_Operation_Insert(); |
529 | $op->execute($this->_dbconn, | |
bbfd46a5 | 530 | $this->createFlatXMLDataSet( |
6a488035 TO |
531 | dirname(__FILE__) . '/activities_for_dashboard_count.xml' |
532 | ) | |
533 | ); | |
534 | ||
535 | $params = array( | |
536 | 'contact_id' => 17, | |
537 | 'admin' => FALSE, | |
538 | 'caseId' => NULL, | |
539 | 'context' => 'home', | |
540 | 'activity_type_id' => NULL, | |
541 | 'offset' => 0, | |
542 | 'rowCount' => 0, | |
543 | 'sort' => NULL, | |
544 | ); | |
545 | $activities = CRM_Activity_BAO_Activity::getActivities($params); | |
546 | ||
547 | //since we are loading activities from dataset, we know total number of activities for this contact | |
548 | // This contact does not have any activities | |
ba4a1892 | 549 | $this->assertEquals(0, count($activities)); |
6a488035 | 550 | } |
96025800 | 551 | |
6a488035 | 552 | } |