test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / Activity / ReturnAssigneeContact.php
1 <?php
2 /**
3 * Test Generated example of using activity get API
4 * Function demonstrates getting asignee_contact_id & using it to get the contact *
5 */
6 function activity_get_example(){
7 $params = array(
8 'activity_id' => 1,
9 'sequential' => 1,
10 'return.assignee_contact_id' => 1,
11 'api.contact.get' => array(
12 'id' => '$value.source_contact_id',
13 ),
14 );
15
16 try{
17 $result = civicrm_api3('activity', 'get', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function
32 */
33 function activity_get_expectedresult(){
34
35 $expectedResult = array(
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 1,
40 'values' => array(
41 '0' => array(
42 'id' => '1',
43 'activity_type_id' => '46',
44 'subject' => 'test activity type id',
45 'activity_date_time' => '2011-06-02 14:36:13',
46 'duration' => '120',
47 'location' => 'Pensulvania',
48 'details' => 'a test activity',
49 'status_id' => '2',
50 'priority_id' => '1',
51 'is_test' => 0,
52 'is_auto' => 0,
53 'is_current_revision' => '1',
54 'is_deleted' => 0,
55 'assignee_contact_id' => array(
56 '0' => '3',
57 ),
58 'source_contact_id' => '1',
59 'api.contact.get' => array(
60 'is_error' => 0,
61 'version' => 3,
62 'count' => 1,
63 'id' => 1,
64 'values' => array(
65 '0' => array(
66 'contact_id' => '1',
67 'contact_type' => 'Individual',
68 'contact_sub_type' => '',
69 'sort_name' => 'Anderson, Anthony',
70 'display_name' => 'Mr. Anthony Anderson II',
71 'do_not_email' => 0,
72 'do_not_phone' => 0,
73 'do_not_mail' => 0,
74 'do_not_sms' => 0,
75 'do_not_trade' => 0,
76 'is_opt_out' => 0,
77 'legal_identifier' => '',
78 'external_identifier' => '',
79 'nick_name' => '',
80 'legal_name' => '',
81 'image_URL' => '',
82 'preferred_mail_format' => 'Both',
83 'first_name' => 'Anthony',
84 'middle_name' => 'J.',
85 'last_name' => 'Anderson',
86 'job_title' => '',
87 'birth_date' => '',
88 'is_deceased' => 0,
89 'deceased_date' => '',
90 'household_name' => '',
91 'organization_name' => '',
92 'sic_code' => '',
93 'contact_is_deleted' => 0,
94 'current_employer' => '',
95 'address_id' => '',
96 'street_address' => '',
97 'supplemental_address_1' => '',
98 'supplemental_address_2' => '',
99 'city' => '',
100 'postal_code_suffix' => '',
101 'postal_code' => '',
102 'geo_code_1' => '',
103 'geo_code_2' => '',
104 'state_province_id' => '',
105 'country_id' => '',
106 'phone_id' => '',
107 'phone_type_id' => '',
108 'phone' => '',
109 'email_id' => '1',
110 'email' => 'anthony_anderson@civicrm.org',
111 'on_hold' => 0,
112 'im_id' => '',
113 'provider_id' => '',
114 'im' => '',
115 'worldregion_id' => '',
116 'world_region' => '',
117 'state_province_name' => '',
118 'state_province' => '',
119 'country' => '',
120 'id' => '1',
121 ),
122 ),
123 ),
124 ),
125 ),
126 );
127
128 return $expectedResult;
129 }
130
131
132 /*
133 * This example has been generated from the API test suite. The test that created it is called
134 *
135 * testActivityGetGoodID1 and can be found in
136 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
137 *
138 * You can see the outcome of the API tests at
139 * http://tests.dev.civicrm.org/trunk/results-api_v3
140 *
141 * To Learn about the API read
142 * http://book.civicrm.org/developer/current/techniques/api/
143 *
144 * and review the wiki at
145 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
146 *
147 * Read more about testing here
148 * http://wiki.civicrm.org/confluence/display/CRM/Testing
149 *
150 * API Standards documentation:
151 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
152 */