Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
9dec4e61 | 3 | * Test Generated example of using profile submit API |
fb32de45 | 4 | * * |
6a488035 | 5 | */ |
9dec4e61 | 6 | function profile_submit_example(){ |
53ca8fd7 | 7 | $params = array( |
c3d3e837 E |
8 | 'profile_id' => 29, |
9 | 'contact_id' => 2, | |
6a488035 TO |
10 | 'first_name' => 'abc2', |
11 | 'last_name' => 'xyz2', | |
c3d3e837 | 12 | 'email-primary' => 'abc2.xyz2@gmail.com', |
6a488035 TO |
13 | 'phone-1-1' => '022 321 826', |
14 | 'country-1' => '1013', | |
15 | 'state_province-1' => '1000', | |
16 | ); | |
17 | ||
fb32de45 | 18 | try{ |
9dec4e61 | 19 | $result = civicrm_api3('profile', 'submit', $params); |
fb32de45 | 20 | } |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // handle error here | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
26 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
27 | } | |
6a488035 | 28 | |
fb32de45 | 29 | return $result; |
6a488035 TO |
30 | } |
31 | ||
fb32de45 | 32 | /** |
6a488035 TO |
33 | * Function returns array of result expected from previous function |
34 | */ | |
9dec4e61 | 35 | function profile_submit_expectedresult(){ |
6a488035 | 36 | |
53ca8fd7 | 37 | $expectedResult = array( |
6a488035 TO |
38 | 'is_error' => 0, |
39 | 'version' => 3, | |
40 | 'count' => 1, | |
c3d3e837 | 41 | 'id' => 2, |
53ca8fd7 | 42 | 'values' => array( |
c3d3e837 E |
43 | '2' => array( |
44 | 'id' => '2', | |
6a488035 TO |
45 | 'contact_type' => 'Individual', |
46 | 'contact_sub_type' => '', | |
47 | 'do_not_email' => 0, | |
48 | 'do_not_phone' => 0, | |
49 | 'do_not_mail' => 0, | |
50 | 'do_not_sms' => 0, | |
51 | 'do_not_trade' => 0, | |
52 | 'is_opt_out' => 0, | |
53 | 'legal_identifier' => '', | |
54 | 'external_identifier' => '', | |
55 | 'sort_name' => 'xyz2, abc2', | |
b259a4ab | 56 | 'display_name' => 'abc2 xyz2', |
6a488035 TO |
57 | 'nick_name' => '', |
58 | 'legal_name' => '', | |
59 | 'image_URL' => '', | |
60 | 'preferred_communication_method' => '', | |
61 | 'preferred_language' => 'en_US', | |
62 | 'preferred_mail_format' => 'Both', | |
63 | 'hash' => '67eac7789eaee00', | |
64 | 'api_key' => '', | |
65 | 'first_name' => 'abc2', | |
e0efd2d0 | 66 | 'middle_name' => 'J.', |
6a488035 | 67 | 'last_name' => 'xyz2', |
29fbb90a | 68 | 'prefix_id' => '3', |
c3d3e837 | 69 | 'suffix_id' => '3', |
6a488035 TO |
70 | 'email_greeting_id' => '1', |
71 | 'email_greeting_custom' => '', | |
fb32de45 | 72 | 'email_greeting_display' => 'Dear abc1', |
6a488035 TO |
73 | 'postal_greeting_id' => '1', |
74 | 'postal_greeting_custom' => '', | |
fb32de45 | 75 | 'postal_greeting_display' => 'Dear abc1', |
6a488035 TO |
76 | 'addressee_id' => '1', |
77 | 'addressee_custom' => '', | |
5a9e1452 | 78 | 'addressee_display' => 'Mr. abc1 J. xyz1 II', |
6a488035 | 79 | 'job_title' => '', |
b259a4ab | 80 | 'gender_id' => '', |
6a488035 TO |
81 | 'birth_date' => '', |
82 | 'is_deceased' => 0, | |
83 | 'deceased_date' => '', | |
84 | 'household_name' => '', | |
85 | 'primary_contact_id' => '', | |
86 | 'organization_name' => '', | |
87 | 'sic_code' => '', | |
88 | 'user_unique_id' => '', | |
f27f2724 | 89 | 'created_date' => '2013-07-28 08:49:19', |
6a488035 TO |
90 | 'modified_date' => '2012-11-14 16:02:35', |
91 | ), | |
92 | ), | |
93 | ); | |
94 | ||
fb32de45 | 95 | return $expectedResult; |
6a488035 TO |
96 | } |
97 | ||
98 | ||
99 | /* | |
100 | * This example has been generated from the API test suite. The test that created it is called | |
101 | * | |
9dec4e61 | 102 | * testProfileSubmit and can be found in |
6a488035 TO |
103 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ProfileTest.php |
104 | * | |
105 | * You can see the outcome of the API tests at | |
106 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
107 | * | |
108 | * To Learn about the API read | |
109 | * http://book.civicrm.org/developer/current/techniques/api/ | |
110 | * | |
111 | * and review the wiki at | |
112 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
113 | * | |
114 | * Read more about testing here | |
115 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
116 | * | |
117 | * API Standards documentation: | |
118 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 119 | */ |