| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example of using profile get API |
| 4 | * * |
| 5 | */ |
| 6 | function profile_get_example(){ |
| 7 | $params = array( |
| 8 | 'profile_id' => array( |
| 9 | '0' => 14, |
| 10 | '1' => 1, |
| 11 | '2' => 'Billing', |
| 12 | ), |
| 13 | 'contact_id' => 2, |
| 14 | ); |
| 15 | |
| 16 | try{ |
| 17 | $result = civicrm_api3('profile', 'get', $params); |
| 18 | } |
| 19 | catch (CiviCRM_API3_Exception $e) { |
| 20 | // handle error here |
| 21 | $errorMessage = $e->getMessage(); |
| 22 | $errorCode = $e->getErrorCode(); |
| 23 | $errorData = $e->getExtraParams(); |
| 24 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); |
| 25 | } |
| 26 | |
| 27 | return $result; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Function returns array of result expected from previous function |
| 32 | */ |
| 33 | function profile_get_expectedresult(){ |
| 34 | |
| 35 | $expectedResult = array( |
| 36 | 'is_error' => 0, |
| 37 | 'version' => 3, |
| 38 | 'count' => 3, |
| 39 | 'values' => array( |
| 40 | '14' => array( |
| 41 | 'postal_code-1' => '90210', |
| 42 | 'state_province-1' => '1021', |
| 43 | 'country-1' => '1228', |
| 44 | 'phone-1-1' => '021 512 755', |
| 45 | 'email-Primary' => 'abc1.xyz1@yahoo.com', |
| 46 | 'last_name' => 'xyz1', |
| 47 | 'first_name' => 'abc1', |
| 48 | 'email-primary' => 'abc1.xyz1@yahoo.com', |
| 49 | ), |
| 50 | '1' => array( |
| 51 | 'first_name' => 'abc1', |
| 52 | 'last_name' => 'xyz1', |
| 53 | 'street_address-1' => '5 Saint Helier St', |
| 54 | 'city-1' => 'Gotham City', |
| 55 | 'postal_code-1' => '90210', |
| 56 | 'country-1' => '1228', |
| 57 | 'state_province-1' => '1021', |
| 58 | ), |
| 59 | 'Billing' => array( |
| 60 | 'billing_first_name' => 'abc1', |
| 61 | 'billing_middle_name' => 'J.', |
| 62 | 'billing_last_name' => 'xyz1', |
| 63 | 'billing_street_address-5' => '5 Saint Helier St', |
| 64 | 'billing_city-5' => 'Gotham City', |
| 65 | 'billing_state_province_id-5' => '1021', |
| 66 | 'billing_country_id-5' => '1228', |
| 67 | 'billing_postal_code-5' => '90210', |
| 68 | 'billing-email-5' => 'abc1.xyz1@yahoo.com', |
| 69 | 'email-5' => 'abc1.xyz1@yahoo.com', |
| 70 | ), |
| 71 | ), |
| 72 | ); |
| 73 | |
| 74 | return $expectedResult; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /* |
| 79 | * This example has been generated from the API test suite. The test that created it is called |
| 80 | * |
| 81 | * testProfileGetMultiple and can be found in |
| 82 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php |
| 83 | * |
| 84 | * You can see the outcome of the API tests at |
| 85 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
| 86 | * |
| 87 | * To Learn about the API read |
| 88 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
| 89 | * |
| 90 | * Browse the api on your own site with the api explorer |
| 91 | * http://MYSITE.ORG/path/to/civicrm/api/explorer |
| 92 | * |
| 93 | * Read more about testing here |
| 94 | * http://wiki.civicrm.org/confluence/display/CRM/Testing |
| 95 | * |
| 96 | * API Standards documentation: |
| 97 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards |
| 98 | */ |