test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / Activity / ReturnAssigneeContact.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using activity get API
4 * Function demonstrates getting asignee_contact_id & using it to get the contact *
6a488035
TO
5 */
6function activity_get_example(){
feb2a730 7$params = array(
6a488035 8 'activity_id' => 1,
6a488035
TO
9 'sequential' => 1,
10 'return.assignee_contact_id' => 1,
feb2a730 11 'api.contact.get' => array(
6a488035
TO
12 'id' => '$value.source_contact_id',
13 ),
14);
15
fb32de45 16try{
17 $result = civicrm_api3('activity', 'get', $params);
18}
19catch (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}
6a488035 26
fb32de45 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function activity_get_expectedresult(){
34
feb2a730 35 $expectedResult = array(
6a488035
TO
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 1,
feb2a730 40 'values' => array(
41 '0' => array(
6a488035 42 'id' => '1',
edb0d67a 43 'activity_type_id' => '46',
6a488035
TO
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,
feb2a730 55 'assignee_contact_id' => array(
9f1b81e0 56 '0' => '3',
6a488035 57 ),
9f1b81e0 58 'source_contact_id' => '1',
feb2a730 59 'api.contact.get' => array(
6a488035
TO
60 'is_error' => 0,
61 'version' => 3,
62 'count' => 1,
9f1b81e0 63 'id' => 1,
feb2a730 64 'values' => array(
65 '0' => array(
9f1b81e0 66 'contact_id' => '1',
6a488035
TO
67 'contact_type' => 'Individual',
68 'contact_sub_type' => '',
9f1b81e0 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,
6a488035
TO
76 'is_opt_out' => 0,
77 'legal_identifier' => '',
78 'external_identifier' => '',
79 'nick_name' => '',
80 'legal_name' => '',
81 'image_URL' => '',
9f1b81e0 82 'preferred_mail_format' => 'Both',
83 'first_name' => 'Anthony',
84 'middle_name' => 'J.',
85 'last_name' => 'Anderson',
6a488035
TO
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,
6a488035
TO
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' => '',
6a488035 105 'country_id' => '',
6a488035
TO
106 'phone_id' => '',
107 'phone_type_id' => '',
108 'phone' => '',
9f1b81e0 109 'email_id' => '1',
110 'email' => 'anthony_anderson@civicrm.org',
111 'on_hold' => 0,
6a488035
TO
112 'im_id' => '',
113 'provider_id' => '',
114 'im' => '',
115 'worldregion_id' => '',
116 'world_region' => '',
9f1b81e0 117 'state_province_name' => '',
118 'state_province' => '',
119 'country' => '',
120 'id' => '1',
6a488035
TO
121 ),
122 ),
123 ),
124 ),
125 ),
126);
127
fb32de45 128 return $expectedResult;
6a488035
TO
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*/