Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Profile.get API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function profile_get_example() { | |
cf8f0fff CW |
9 | $params = [ |
10 | 'profile_id' => [ | |
89bf81b4 | 11 | '0' => 15, |
f01ce56b | 12 | '1' => 1, |
13 | '2' => 'Billing', | |
cf8f0fff | 14 | ], |
8390b11b | 15 | 'contact_id' => 5, |
cf8f0fff | 16 | ]; |
6a488035 | 17 | |
50fb255d | 18 | try{ |
a828d7b8 | 19 | $result = civicrm_api3('Profile', 'get', $params); |
50fb255d | 20 | } |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // Handle error here. | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 26 | return [ |
1d8ee3d6 | 27 | 'is_error' => 1, |
28 | 'error_message' => $errorMessage, | |
50fb255d | 29 | 'error_code' => $errorCode, |
30 | 'error_data' => $errorData, | |
cf8f0fff | 31 | ]; |
50fb255d | 32 | } |
6a488035 | 33 | |
50fb255d | 34 | return $result; |
6a488035 TO |
35 | } |
36 | ||
fb32de45 | 37 | /** |
50fb255d | 38 | * Function returns array of result expected from previous function. |
39 | * | |
40 | * @return array | |
41 | * API result array | |
6a488035 | 42 | */ |
50fb255d | 43 | function profile_get_expectedresult() { |
6a488035 | 44 | |
cf8f0fff | 45 | $expectedResult = [ |
50fb255d | 46 | 'is_error' => 0, |
47 | 'version' => 3, | |
48 | 'count' => 3, | |
cf8f0fff CW |
49 | 'values' => [ |
50 | '15' => [ | |
50fb255d | 51 | 'postal_code-1' => '90210', |
52 | 'state_province-1' => '1021', | |
53 | 'country-1' => '1228', | |
54 | 'phone-1-1' => '021 512 755', | |
55 | 'email-Primary' => 'abc1.xyz1@yahoo.com', | |
56 | 'last_name' => 'xyz1', | |
57 | 'first_name' => 'abc1', | |
58 | 'email-primary' => 'abc1.xyz1@yahoo.com', | |
cf8f0fff CW |
59 | ], |
60 | '1' => [ | |
50fb255d | 61 | 'first_name' => 'abc1', |
62 | 'last_name' => 'xyz1', | |
63 | 'street_address-1' => '5 Saint Helier St', | |
64 | 'city-1' => 'Gotham City', | |
65 | 'postal_code-1' => '90210', | |
66 | 'country-1' => '1228', | |
67 | 'state_province-1' => '1021', | |
cf8f0fff CW |
68 | ], |
69 | 'Billing' => [ | |
50fb255d | 70 | 'billing_first_name' => 'abc1', |
71 | 'billing_middle_name' => 'J.', | |
72 | 'billing_last_name' => 'xyz1', | |
73 | 'billing_street_address-5' => '5 Saint Helier St', | |
74 | 'billing_city-5' => 'Gotham City', | |
75 | 'billing_state_province_id-5' => '1021', | |
76 | 'billing_country_id-5' => '1228', | |
77 | 'billing_postal_code-5' => '90210', | |
78 | 'billing-email-5' => 'abc1.xyz1@yahoo.com', | |
79 | 'email-5' => 'abc1.xyz1@yahoo.com', | |
cf8f0fff CW |
80 | ], |
81 | ], | |
82 | ]; | |
6a488035 | 83 | |
fb32de45 | 84 | return $expectedResult; |
6a488035 TO |
85 | } |
86 | ||
a828d7b8 | 87 | /* |
50fb255d | 88 | * This example has been generated from the API test suite. |
a828d7b8 CW |
89 | * The test that created it is called "testProfileGetMultiple" |
90 | * and can be found at: | |
69d79249 | 91 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php |
6a488035 TO |
92 | * |
93 | * You can see the outcome of the API tests at | |
8390b11b | 94 | * https://test.civicrm.org/job/CiviCRM-Core-Matrix/ |
6a488035 TO |
95 | * |
96 | * To Learn about the API read | |
8390b11b | 97 | * https://docs.civicrm.org/dev/en/latest/api/ |
6a488035 | 98 | * |
8390b11b SL |
99 | * Browse the API on your own site with the API Explorer. It is in the main |
100 | * CiviCRM menu, under: Support > Development > API Explorer. | |
6a488035 TO |
101 | * |
102 | * Read more about testing here | |
8390b11b | 103 | * https://docs.civicrm.org/dev/en/latest/testing/ |
6a488035 TO |
104 | * |
105 | * API Standards documentation: | |
8390b11b | 106 | * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/ |
b259a4ab | 107 | */ |