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