Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Profile.submit API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function profile_submit_example() { | |
cf8f0fff | 9 | $params = [ |
8390b11b SL |
10 | 'profile_id' => 24, |
11 | 'contact_id' => 5, | |
50fb255d | 12 | 'first_name' => 'abc2', |
13 | 'last_name' => 'xyz2', | |
14 | 'email-primary' => 'abc2.xyz2@gmail.com', | |
15 | 'phone-1-1' => '022 321 826', | |
16 | 'country-1' => '1013', | |
17 | 'state_province-1' => '1000', | |
cf8f0fff | 18 | ]; |
6a488035 | 19 | |
50fb255d | 20 | try{ |
a828d7b8 | 21 | $result = civicrm_api3('Profile', 'submit', $params); |
50fb255d | 22 | } |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // Handle error here. | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 28 | return [ |
1d8ee3d6 | 29 | 'is_error' => 1, |
30 | 'error_message' => $errorMessage, | |
50fb255d | 31 | 'error_code' => $errorCode, |
32 | 'error_data' => $errorData, | |
cf8f0fff | 33 | ]; |
50fb255d | 34 | } |
35 | ||
36 | return $result; | |
6a488035 TO |
37 | } |
38 | ||
fb32de45 | 39 | /** |
50fb255d | 40 | * Function returns array of result expected from previous function. |
41 | * | |
42 | * @return array | |
43 | * API result array | |
6a488035 | 44 | */ |
50fb255d | 45 | function profile_submit_expectedresult() { |
6a488035 | 46 | |
cf8f0fff | 47 | $expectedResult = [ |
50fb255d | 48 | 'is_error' => 0, |
49 | 'version' => 3, | |
50 | 'count' => 1, | |
8390b11b | 51 | 'id' => 5, |
cf8f0fff | 52 | 'values' => [ |
8390b11b SL |
53 | '5' => [ |
54 | 'id' => '5', | |
50fb255d | 55 | 'contact_type' => 'Individual', |
56 | 'contact_sub_type' => '', | |
57 | 'do_not_email' => 0, | |
58 | 'do_not_phone' => 0, | |
59 | 'do_not_mail' => 0, | |
60 | 'do_not_sms' => 0, | |
61 | 'do_not_trade' => 0, | |
62 | 'is_opt_out' => 0, | |
63 | 'legal_identifier' => '', | |
64 | 'external_identifier' => '', | |
65 | 'sort_name' => 'xyz2, abc2', | |
66 | 'display_name' => 'Mr. abc2 xyz2 II', | |
67 | 'nick_name' => '', | |
68 | 'legal_name' => '', | |
69 | 'image_URL' => '', | |
70 | 'preferred_communication_method' => '', | |
71 | 'preferred_language' => 'en_US', | |
72 | 'preferred_mail_format' => 'Both', | |
73 | 'hash' => '67eac7789eaee00', | |
74 | 'api_key' => '', | |
75 | 'first_name' => 'abc2', | |
76 | 'middle_name' => 'J.', | |
77 | 'last_name' => 'xyz2', | |
78 | 'prefix_id' => '3', | |
79 | 'suffix_id' => '3', | |
80 | 'formal_title' => '', | |
8390b11b | 81 | 'communication_style_id' => '1', |
50fb255d | 82 | 'email_greeting_id' => '1', |
83 | 'email_greeting_custom' => '', | |
84 | 'email_greeting_display' => 'Dear abc1', | |
85 | 'postal_greeting_id' => '1', | |
86 | 'postal_greeting_custom' => '', | |
87 | 'postal_greeting_display' => 'Dear abc1', | |
88 | 'addressee_id' => '1', | |
89 | 'addressee_custom' => '', | |
90 | 'addressee_display' => 'Mr. abc1 J. xyz1 II', | |
91 | 'job_title' => '', | |
92 | 'gender_id' => '', | |
93 | 'birth_date' => '', | |
94 | 'is_deceased' => 0, | |
95 | 'deceased_date' => '', | |
96 | 'household_name' => '', | |
97 | 'primary_contact_id' => '', | |
98 | 'organization_name' => '', | |
99 | 'sic_code' => '', | |
100 | 'user_unique_id' => '', | |
101 | 'created_date' => '2013-07-28 08:49:19', | |
102 | 'modified_date' => '2012-11-14 16:02:35', | |
cf8f0fff CW |
103 | ], |
104 | ], | |
105 | ]; | |
6a488035 | 106 | |
fb32de45 | 107 | return $expectedResult; |
6a488035 TO |
108 | } |
109 | ||
a828d7b8 | 110 | /* |
50fb255d | 111 | * This example has been generated from the API test suite. |
a828d7b8 CW |
112 | * The test that created it is called "testProfileSubmit" |
113 | * and can be found at: | |
69d79249 | 114 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php |
6a488035 TO |
115 | * |
116 | * You can see the outcome of the API tests at | |
8390b11b | 117 | * https://test.civicrm.org/job/CiviCRM-Core-Matrix/ |
6a488035 TO |
118 | * |
119 | * To Learn about the API read | |
8390b11b | 120 | * https://docs.civicrm.org/dev/en/latest/api/ |
6a488035 | 121 | * |
8390b11b SL |
122 | * Browse the API on your own site with the API Explorer. It is in the main |
123 | * CiviCRM menu, under: Support > Development > API Explorer. | |
6a488035 TO |
124 | * |
125 | * Read more about testing here | |
8390b11b | 126 | * https://docs.civicrm.org/dev/en/latest/testing/ |
6a488035 TO |
127 | * |
128 | * API Standards documentation: | |
8390b11b | 129 | * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/ |
b259a4ab | 130 | */ |