Merge pull request #6037 from colemanw/CRM-16512
[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 'error' => $errorMessage,
57 'error_code' => $errorCode,
58 'error_data' => $errorData,
59 );
60 }
61
62 return $result;
63 }
64
65 /**
66 * Function returns array of result expected from previous function.
67 *
68 * @return array
69 * API result array
70 */
71 function uf_field_replace_expectedresult() {
72
73 $expectedResult = array(
74 'is_error' => 0,
75 'version' => 3,
76 'count' => 3,
77 'values' => array(
78 '1' => array(
79 'id' => '1',
80 'uf_group_id' => '11',
81 'field_name' => 'first_name',
82 'is_active' => '1',
83 'is_view' => '',
84 'is_required' => '',
85 'weight' => '3',
86 'help_post' => '',
87 'help_pre' => '',
88 'visibility' => 'Public Pages and Listings',
89 'in_selector' => '',
90 'is_searchable' => '1',
91 'location_type_id' => '',
92 'phone_type_id' => '',
93 'website_type_id' => '',
94 'label' => 'Test First Name',
95 'field_type' => 'Contact',
96 'is_reserved' => '',
97 'is_multi_summary' => '',
98 ),
99 '2' => array(
100 'id' => '2',
101 'uf_group_id' => '11',
102 'field_name' => 'country',
103 'is_active' => '1',
104 'is_view' => '',
105 'is_required' => '',
106 'weight' => '2',
107 'help_post' => '',
108 'help_pre' => '',
109 'visibility' => 'Public Pages and Listings',
110 'in_selector' => '',
111 'is_searchable' => '1',
112 'location_type_id' => '1',
113 'phone_type_id' => '',
114 'website_type_id' => '',
115 'label' => 'Test Country',
116 'field_type' => 'Contact',
117 'is_reserved' => '',
118 'is_multi_summary' => '',
119 ),
120 '3' => array(
121 'id' => '3',
122 'uf_group_id' => '11',
123 'field_name' => 'phone',
124 'is_active' => '1',
125 'is_view' => '',
126 'is_required' => '',
127 'weight' => '1',
128 'help_post' => '',
129 'help_pre' => '',
130 'visibility' => 'Public Pages and Listings',
131 'in_selector' => '',
132 'is_searchable' => '1',
133 'location_type_id' => '1',
134 'phone_type_id' => '1',
135 'website_type_id' => '',
136 'label' => 'Test Phone',
137 'field_type' => 'Contact',
138 'is_reserved' => '',
139 'is_multi_summary' => '',
140 ),
141 ),
142 );
143
144 return $expectedResult;
145 }
146
147 /*
148 * This example has been generated from the API test suite.
149 * The test that created it is called "testReplaceUFFields"
150 * and can be found at:
151 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFFieldTest.php
152 *
153 * You can see the outcome of the API tests at
154 * https://test.civicrm.org/job/CiviCRM-master-git/
155 *
156 * To Learn about the API read
157 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
158 *
159 * Browse the api on your own site with the api explorer
160 * http://MYSITE.ORG/path/to/civicrm/api
161 *
162 * Read more about testing here
163 * http://wiki.civicrm.org/confluence/display/CRM/Testing
164 *
165 * API Standards documentation:
166 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
167 */