9827fb70 |
1 | <?php |
2 | |
3 | /** |
4 | * @group headless |
5 | */ |
6 | class CRM_Activity_Form_ActivityViewTest extends CiviUnitTestCase { |
7 | |
8 | public function setUp() { |
9 | parent::setUp(); |
10 | } |
11 | |
12 | public function tearDown() { |
13 | $tablesToTruncate = [ |
14 | 'civicrm_activity', |
15 | 'civicrm_activity_contact', |
16 | ]; |
17 | $this->quickCleanup($tablesToTruncate); |
18 | } |
19 | |
20 | /** |
21 | * Test that the smarty template for ActivityView contains what we expect |
22 | * after preProcess(). |
23 | */ |
24 | public function testActivityViewPreProcess() { |
25 | // create activity |
26 | $activity = $this->activityCreate(); |
27 | |
28 | // $activity doesn't contain everything we need, so do another get call |
29 | $activityMoreInfo = $this->callAPISuccess('activity', 'getsingle', ['id' => $activity['id']]); |
30 | |
31 | // do preProcess |
32 | $activityViewForm = new CRM_Activity_Form_ActivityView(); |
33 | $activityViewForm->controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_ActivityView', 'Activity'); |
34 | $activityViewForm->set('id', $activity['id']); |
35 | $activityViewForm->set('context', 'activity'); |
36 | $activityViewForm->set('cid', $activity['target_contact_id']); |
37 | $activityViewForm->preProcess(); |
38 | |
39 | // check one of the smarty template vars |
40 | // not checking EVERYTHING |
41 | $templateVar = $activityViewForm->getTemplate()->get_template_vars('values'); |
42 | $expected = [ |
43 | 'assignee_contact' => [0 => $activity['target_contact_id']], |
44 | // it's always Julia |
45 | 'assignee_contact_value' => 'Anderson, Julia', |
46 | 'target_contact' => [0 => $activity['target_contact_id']], |
47 | 'target_contact_value' => 'Anderson, Julia', |
48 | 'source_contact' => $activityMoreInfo['source_contact_sort_name'], |
49 | 'case_subject' => NULL, |
50 | 'id' => (int) $activity['id'], |
51 | 'subject' => $activity['values'][$activity['id']]['subject'], |
52 | 'activity_subject' => $activity['values'][$activity['id']]['subject'], |
53 | 'activity_date_time' => $activityMoreInfo['activity_date_time'], |
54 | 'location' => $activity['values'][$activity['id']]['location'], |
55 | 'activity_location' => $activity['values'][$activity['id']]['location'], |
56 | 'details' => $activity['values'][$activity['id']]['details'], |
57 | 'activity_details' => $activity['values'][$activity['id']]['details'], |
58 | 'is_test' => '0', |
59 | 'activity_is_test' => '0', |
60 | 'is_auto' => '0', |
61 | 'is_current_revision' => '1', |
62 | 'is_deleted' => '0', |
63 | 'activity_is_deleted' => '0', |
64 | 'is_star' => '0', |
65 | 'created_date' => $activityMoreInfo['created_date'], |
66 | 'activity_created_date' => $activityMoreInfo['created_date'], |
67 | 'modified_date' => $activityMoreInfo['modified_date'], |
68 | 'activity_modified_date' => $activityMoreInfo['modified_date'], |
69 | 'attachment' => NULL, |
70 | ]; |
71 | |
72 | $this->assertEquals($expected, $templateVar); |
73 | } |
74 | |
75 | } |