Merge pull request #2704 from jitendrapurohit/CRM_TestFix
[civicrm-core.git] / api / v3 / examples / Group / getfields.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using group getfields API
4 * demonstrate use of getfields to interogate api *
6a488035
TO
5 */
6function group_getfields_example(){
53ca8fd7 7$params = array(
6a488035
TO
8 'action' => 'create',
9);
10
fb32de45 11try{
12 $result = civicrm_api3('group', 'getfields', $params);
13}
14catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20}
6a488035 21
fb32de45 22return $result;
6a488035
TO
23}
24
fb32de45 25/**
6a488035
TO
26 * Function returns array of result expected from previous function
27 */
28function group_getfields_expectedresult(){
29
53ca8fd7 30 $expectedResult = array(
6a488035
TO
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 19,
53ca8fd7 34 'values' => array(
35 'id' => array(
6a488035
TO
36 'name' => 'id',
37 'type' => 1,
38 'title' => 'Group ID',
39 'required' => true,
53ca8fd7 40 'api.aliases' => array(
41 '0' => 'group_id',
42 ),
6a488035 43 ),
53ca8fd7 44 'name' => array(
6a488035
TO
45 'name' => 'name',
46 'type' => 2,
47 'title' => 'Group Name',
48 'maxlength' => 64,
49 'size' => 30,
50 ),
53ca8fd7 51 'title' => array(
6a488035
TO
52 'name' => 'title',
53 'type' => 2,
54 'title' => 'Group Title',
55 'maxlength' => 64,
56 'size' => 30,
57 'api.required' => 1,
58 ),
53ca8fd7 59 'description' => array(
6a488035
TO
60 'name' => 'description',
61 'type' => 32,
62 'title' => 'Group Description',
63 'rows' => 2,
64 'cols' => 60,
65 ),
53ca8fd7 66 'source' => array(
6a488035
TO
67 'name' => 'source',
68 'type' => 2,
69 'title' => 'Group Source',
70 'maxlength' => 64,
71 'size' => 30,
72 ),
53ca8fd7 73 'saved_search_id' => array(
6a488035
TO
74 'name' => 'saved_search_id',
75 'type' => 1,
76 'title' => 'Saved Search ID',
77 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
78 ),
53ca8fd7 79 'is_active' => array(
6a488035
TO
80 'name' => 'is_active',
81 'type' => 16,
82 'title' => 'Group Enabled',
83 'api.default' => 1,
84 ),
53ca8fd7 85 'visibility' => array(
6a488035
TO
86 'name' => 'visibility',
87 'type' => 2,
88 'title' => 'Group Visibility Setting',
89 'default' => 'User and User Admin Only',
90 'enumValues' => 'User and User Admin Only,Public Pages',
6a488035 91 ),
53ca8fd7 92 'where_clause' => array(
6a488035
TO
93 'name' => 'where_clause',
94 'type' => 32,
95 'title' => 'Group Where Clause',
96 ),
53ca8fd7 97 'select_tables' => array(
6a488035
TO
98 'name' => 'select_tables',
99 'type' => 32,
100 'title' => 'Tables For Select Clause',
101 ),
53ca8fd7 102 'where_tables' => array(
6a488035
TO
103 'name' => 'where_tables',
104 'type' => 32,
105 'title' => 'Tables For Where Clause',
106 ),
53ca8fd7 107 'group_type' => array(
6a488035
TO
108 'name' => 'group_type',
109 'type' => 2,
110 'title' => 'Group Type',
111 'maxlength' => 128,
112 'size' => 45,
113 ),
53ca8fd7 114 'cache_date' => array(
6a488035
TO
115 'name' => 'cache_date',
116 'type' => 12,
117 'title' => 'Group Cache Date',
118 ),
53ca8fd7 119 'refresh_date' => array(
6a488035
TO
120 'name' => 'refresh_date',
121 'type' => 12,
122 'title' => 'Next Group Refresh Time',
123 ),
53ca8fd7 124 'parents' => array(
6a488035
TO
125 'name' => 'parents',
126 'type' => 32,
127 'title' => 'Group Parents',
128 ),
53ca8fd7 129 'children' => array(
6a488035
TO
130 'name' => 'children',
131 'type' => 32,
132 'title' => 'Group Children',
133 ),
53ca8fd7 134 'is_hidden' => array(
6a488035
TO
135 'name' => 'is_hidden',
136 'type' => 16,
137 'title' => 'Group is Hidden',
138 ),
53ca8fd7 139 'is_reserved' => array(
6a488035
TO
140 'name' => 'is_reserved',
141 'type' => 16,
142 'title' => 'Group is Reserved',
143 ),
53ca8fd7 144 'created_id' => array(
6a488035
TO
145 'name' => 'created_id',
146 'type' => 1,
147 'title' => 'Group Created By',
148 'FKClassName' => 'CRM_Contact_DAO_Contact',
149 ),
150 ),
151);
152
fb32de45 153 return $expectedResult;
6a488035
TO
154}
155
156
157/*
158* This example has been generated from the API test suite. The test that created it is called
159*
160* testgetfields and can be found in
69d79249 161* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupTest.php
6a488035
TO
162*
163* You can see the outcome of the API tests at
69d79249 164* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
165*
166* To Learn about the API read
69d79249 167* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 168*
69d79249
E
169* Browse the api on your own site with the api explorer
170* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
171*
172* Read more about testing here
173* http://wiki.civicrm.org/confluence/display/CRM/Testing
174*
175* API Standards documentation:
176* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 177*/