Merge pull request #4246 from crusonweb/CRM-15310
[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 'website_type_id' => '',
84 'label' => 'Test First Name',
85 'field_type' => 'Contact',
86 'is_reserved' => '',
87 'is_multi_summary' => '',
88 ),
89 '2' => array(
90 'id' => '2',
91 'uf_group_id' => '11',
92 'field_name' => 'country',
93 'is_active' => '1',
94 'is_view' => '',
95 'is_required' => '',
96 'weight' => '2',
97 'help_post' => '',
98 'help_pre' => '',
99 'visibility' => 'Public Pages and Listings',
100 'in_selector' => '',
101 'is_searchable' => '1',
102 'location_type_id' => '1',
103 'phone_type_id' => '',
104 'website_type_id' => '',
105 'label' => 'Test Country',
106 'field_type' => 'Contact',
107 'is_reserved' => '',
108 'is_multi_summary' => '',
109 ),
110 '3' => array(
111 'id' => '3',
112 'uf_group_id' => '11',
113 'field_name' => 'phone',
114 'is_active' => '1',
115 'is_view' => '',
116 'is_required' => '',
117 'weight' => '1',
118 'help_post' => '',
119 'help_pre' => '',
120 'visibility' => 'Public Pages and Listings',
121 'in_selector' => '',
122 'is_searchable' => '1',
123 'location_type_id' => '1',
124 'phone_type_id' => '1',
125 'website_type_id' => '',
126 'label' => 'Test Phone',
127 'field_type' => 'Contact',
128 'is_reserved' => '',
129 'is_multi_summary' => '',
130 ),
131 ),
132 );
133
134 return $expectedResult;
135 }
136
137
138 /*
139 * This example has been generated from the API test suite. The test that created it is called
140 *
141 * testReplaceUFFields and can be found in
142 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFFieldTest.php
143 *
144 * You can see the outcome of the API tests at
145 * https://test.civicrm.org/job/CiviCRM-master-git/
146 *
147 * To Learn about the API read
148 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
149 *
150 * Browse the api on your own site with the api explorer
151 * http://MYSITE.ORG/path/to/civicrm/api/explorer
152 *
153 * Read more about testing here
154 * http://wiki.civicrm.org/confluence/display/CRM/Testing
155 *
156 * API Standards documentation:
157 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
158 */