Merge pull request #9947 from davidjosephhayes/master
[civicrm-core.git] / api / v3 / examples / UFField / Replace.php
1 <?php
2 /**
3 * Test Generated example demonstrating the UFField.replace API.
4 *
5 * @return array
6 * API result array
7 */
8 function uf_field_replace_example() {
9 $params = array(
10 'uf_group_id' => 11,
11 'option.autoweight' => '',
12 'values' => array(
13 '0' => array(
14 'field_name' => 'first_name',
15 'field_type' => 'Contact',
16 'visibility' => 'Public Pages and Listings',
17 'weight' => 3,
18 'label' => 'Test First Name',
19 'is_searchable' => 1,
20 'is_active' => 1,
21 ),
22 '1' => array(
23 'field_name' => 'country',
24 'field_type' => 'Contact',
25 'visibility' => 'Public Pages and Listings',
26 'weight' => 2,
27 'label' => 'Test Country',
28 'is_searchable' => 1,
29 'is_active' => 1,
30 'location_type_id' => 1,
31 ),
32 '2' => array(
33 'field_name' => 'phone',
34 'field_type' => 'Contact',
35 'visibility' => 'Public Pages and Listings',
36 'weight' => 1,
37 'label' => 'Test Phone',
38 'is_searchable' => 1,
39 'is_active' => 1,
40 'location_type_id' => 1,
41 'phone_type_id' => 1,
42 ),
43 ),
44 'check_permissions' => TRUE,
45 );
46
47 try{
48 $result = civicrm_api3('UFField', 'replace', $params);
49 }
50 catch (CiviCRM_API3_Exception $e) {
51 // Handle error here.
52 $errorMessage = $e->getMessage();
53 $errorCode = $e->getErrorCode();
54 $errorData = $e->getExtraParams();
55 return array(
56 'is_error' => 1,
57 'error_message' => $errorMessage,
58 'error_code' => $errorCode,
59 'error_data' => $errorData,
60 );
61 }
62
63 return $result;
64 }
65
66 /**
67 * Function returns array of result expected from previous function.
68 *
69 * @return array
70 * API result array
71 */
72 function uf_field_replace_expectedresult() {
73
74 $expectedResult = array(
75 'is_error' => 0,
76 'version' => 3,
77 'count' => 3,
78 'values' => array(
79 '1' => array(
80 'id' => '1',
81 'uf_group_id' => '11',
82 'field_name' => 'first_name',
83 'is_active' => '1',
84 'is_view' => '',
85 'is_required' => '',
86 'weight' => '3',
87 'help_post' => '',
88 'help_pre' => '',
89 'visibility' => 'Public Pages and Listings',
90 'in_selector' => '',
91 'is_searchable' => '1',
92 'location_type_id' => '',
93 'phone_type_id' => '',
94 'website_type_id' => '',
95 'label' => 'Test First Name',
96 'field_type' => 'Contact',
97 'is_reserved' => '',
98 'is_multi_summary' => '',
99 ),
100 '2' => array(
101 'id' => '2',
102 'uf_group_id' => '11',
103 'field_name' => 'country',
104 'is_active' => '1',
105 'is_view' => '',
106 'is_required' => '',
107 'weight' => '2',
108 'help_post' => '',
109 'help_pre' => '',
110 'visibility' => 'Public Pages and Listings',
111 'in_selector' => '',
112 'is_searchable' => '1',
113 'location_type_id' => '1',
114 'phone_type_id' => '',
115 'website_type_id' => '',
116 'label' => 'Test Country',
117 'field_type' => 'Contact',
118 'is_reserved' => '',
119 'is_multi_summary' => '',
120 ),
121 '3' => array(
122 'id' => '3',
123 'uf_group_id' => '11',
124 'field_name' => 'phone',
125 'is_active' => '1',
126 'is_view' => '',
127 'is_required' => '',
128 'weight' => '1',
129 'help_post' => '',
130 'help_pre' => '',
131 'visibility' => 'Public Pages and Listings',
132 'in_selector' => '',
133 'is_searchable' => '1',
134 'location_type_id' => '1',
135 'phone_type_id' => '1',
136 'website_type_id' => '',
137 'label' => 'Test Phone',
138 'field_type' => 'Contact',
139 'is_reserved' => '',
140 'is_multi_summary' => '',
141 ),
142 ),
143 );
144
145 return $expectedResult;
146 }
147
148 /*
149 * This example has been generated from the API test suite.
150 * The test that created it is called "testReplaceUFFields"
151 * and can be found at:
152 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFFieldTest.php
153 *
154 * You can see the outcome of the API tests at
155 * https://test.civicrm.org/job/CiviCRM-master-git/
156 *
157 * To Learn about the API read
158 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
159 *
160 * Browse the api on your own site with the api explorer
161 * http://MYSITE.ORG/path/to/civicrm/api
162 *
163 * Read more about testing here
164 * http://wiki.civicrm.org/confluence/display/CRM/Testing
165 *
166 * API Standards documentation:
167 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
168 */