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