3 * Test Generated example of using email replace API
4 * example demonstrates use of Replace in a nested API call *
6 function email_replace_example(){
9 'api.email.replace' => array(
12 'location_type_id' => 20,
13 'email' => '1-1@example.com',
17 'location_type_id' => 20,
18 'email' => '1-2@example.com',
22 'location_type_id' => 20,
23 'email' => '1-3@example.com',
27 'location_type_id' => 21,
28 'email' => '2-1@example.com',
32 'location_type_id' => 21,
33 'email' => '2-2@example.com',
41 $result = civicrm_api3('email', 'replace', $params);
43 catch (CiviCRM_API3_Exception
$e) {
45 $errorMessage = $e->getMessage();
46 $errorCode = $e->getErrorCode();
47 $errorData = $e->getExtraParams();
48 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
55 * Function returns array of result expected from previous function
57 function email_replace_expectedresult(){
59 $expectedResult = array(
67 'contact_type' => 'Organization',
68 'contact_sub_type' => '',
69 'sort_name' => 'Unit Test Organization',
70 'display_name' => 'Unit Test Organization',
77 'legal_identifier' => '',
78 'external_identifier' => '',
82 'preferred_communication_method' => '',
83 'preferred_language' => 'en_US',
84 'preferred_mail_format' => 'Both',
91 'communication_style_id' => '',
96 'deceased_date' => '',
97 'household_name' => '',
98 'organization_name' => 'Unit Test Organization',
100 'contact_is_deleted' => 0,
101 'current_employer' => '',
103 'street_address' => '',
104 'supplemental_address_1' => '',
105 'supplemental_address_2' => '',
107 'postal_code_suffix' => '',
111 'state_province_id' => '',
114 'phone_type_id' => '',
122 'worldregion_id' => '',
123 'world_region' => '',
124 'individual_prefix' => '',
125 'individual_suffix' => '',
126 'communication_style' => '',
128 'state_province_name' => '',
129 'state_province' => '',
132 'api.email.replace' => array(
139 'contact_id' => '10',
140 'location_type_id' => '20',
141 'email' => '1-1@example.com',
148 'signature_text' => '',
149 'signature_html' => '',
153 'contact_id' => '10',
154 'location_type_id' => '20',
155 'email' => '1-2@example.com',
162 'signature_text' => '',
163 'signature_html' => '',
167 'contact_id' => '10',
168 'location_type_id' => '20',
169 'email' => '1-3@example.com',
176 'signature_text' => '',
177 'signature_html' => '',
181 'contact_id' => '10',
182 'location_type_id' => '21',
183 'email' => '2-1@example.com',
190 'signature_text' => '',
191 'signature_html' => '',
195 'contact_id' => '10',
196 'location_type_id' => '21',
197 'email' => '2-2@example.com',
204 'signature_text' => '',
205 'signature_html' => '',
213 return $expectedResult;
218 * This example has been generated from the API test suite. The test that created it is called
220 * testReplaceEmailsInChain and can be found in
221 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php
223 * You can see the outcome of the API tests at
224 * https://test.civicrm.org/job/CiviCRM-master-git/
226 * To Learn about the API read
227 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
229 * Browse the api on your own site with the api explorer
230 * http://MYSITE.ORG/path/to/civicrm/api/explorer
232 * Read more about testing here
233 * http://wiki.civicrm.org/confluence/display/CRM/Testing
235 * API Standards documentation:
236 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards