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