Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the UFField.get API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function uf_field_get_example() { | |
9 | $params = array(); | |
6a488035 | 10 | |
50fb255d | 11 | try{ |
a828d7b8 | 12 | $result = civicrm_api3('UFField', 'get', $params); |
50fb255d | 13 | } |
14 | catch (CiviCRM_API3_Exception $e) { | |
15 | // Handle error here. | |
16 | $errorMessage = $e->getMessage(); | |
17 | $errorCode = $e->getErrorCode(); | |
18 | $errorData = $e->getExtraParams(); | |
19 | return array( | |
20 | 'error' => $errorMessage, | |
21 | 'error_code' => $errorCode, | |
22 | 'error_data' => $errorData, | |
23 | ); | |
24 | } | |
25 | ||
26 | return $result; | |
6a488035 TO |
27 | } |
28 | ||
fb32de45 | 29 | /** |
50fb255d | 30 | * Function returns array of result expected from previous function. |
31 | * | |
32 | * @return array | |
33 | * API result array | |
6a488035 | 34 | */ |
50fb255d | 35 | function uf_field_get_expectedresult() { |
6a488035 | 36 | |
ee600d6f | 37 | $expectedResult = array( |
50fb255d | 38 | 'is_error' => 0, |
39 | 'version' => 3, | |
40 | 'count' => 1, | |
41 | 'id' => 1, | |
42 | 'values' => array( | |
ee600d6f | 43 | '1' => array( |
50fb255d | 44 | 'id' => '1', |
45 | 'uf_group_id' => '11', | |
46 | 'field_name' => 'phone', | |
47 | 'is_active' => '1', | |
48 | 'is_view' => 0, | |
49 | 'is_required' => 0, | |
50 | 'weight' => '1', | |
51 | 'visibility' => 'Public Pages and Listings', | |
52 | 'in_selector' => 0, | |
53 | 'is_searchable' => '1', | |
54 | 'location_type_id' => '1', | |
55 | 'phone_type_id' => '1', | |
56 | 'label' => 'Test Phone', | |
57 | 'field_type' => 'Contact', | |
58 | 'is_multi_summary' => 0, | |
59 | ), | |
6a488035 | 60 | ), |
50fb255d | 61 | ); |
6a488035 | 62 | |
fb32de45 | 63 | return $expectedResult; |
6a488035 TO |
64 | } |
65 | ||
a828d7b8 | 66 | /* |
50fb255d | 67 | * This example has been generated from the API test suite. |
a828d7b8 CW |
68 | * The test that created it is called "testGetUFFieldSuccess" |
69 | * and can be found at: | |
69d79249 | 70 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFFieldTest.php |
6a488035 TO |
71 | * |
72 | * You can see the outcome of the API tests at | |
69d79249 | 73 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
74 | * |
75 | * To Learn about the API read | |
69d79249 | 76 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 77 | * |
69d79249 | 78 | * Browse the api on your own site with the api explorer |
41d4d31f | 79 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
80 | * |
81 | * Read more about testing here | |
82 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
83 | * | |
84 | * API Standards documentation: | |
85 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 86 | */ |