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', | |
e0efd2d0 | 56 | 'display_name' => 'Mr. abc2 xyz2 II', |
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' => '', |
6a488035 TO |
80 | 'birth_date' => '', |
81 | 'is_deceased' => 0, | |
82 | 'deceased_date' => '', | |
83 | 'household_name' => '', | |
84 | 'primary_contact_id' => '', | |
85 | 'organization_name' => '', | |
86 | 'sic_code' => '', | |
87 | 'user_unique_id' => '', | |
f27f2724 | 88 | 'created_date' => '2013-07-28 08:49:19', |
6a488035 TO |
89 | 'modified_date' => '2012-11-14 16:02:35', |
90 | ), | |
91 | ), | |
92 | ); | |
93 | ||
fb32de45 | 94 | return $expectedResult; |
6a488035 TO |
95 | } |
96 | ||
97 | ||
98 | /* | |
99 | * This example has been generated from the API test suite. The test that created it is called | |
100 | * | |
9dec4e61 | 101 | * testProfileSubmit and can be found in |
6a488035 TO |
102 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ProfileTest.php |
103 | * | |
104 | * You can see the outcome of the API tests at | |
105 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
106 | * | |
107 | * To Learn about the API read | |
108 | * http://book.civicrm.org/developer/current/techniques/api/ | |
109 | * | |
110 | * and review the wiki at | |
111 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
112 | * | |
113 | * Read more about testing here | |
114 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
115 | * | |
116 | * API Standards documentation: | |
117 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
118 | */ |