commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / api / v3 / examples / Tag / GetFields.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Tag.getfields API.
4 *
5 * Demonstrate use of getfields to interrogate api.
6 *
7 * @return array
8 * API result array
9 */
10 function tag_getfields_example() {
11 $params = array(
12 'action' => 'create',
13 );
14
15 try{
16 $result = civicrm_api3('Tag', 'getfields', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
24 'error' => $errorMessage,
25 'error_code' => $errorCode,
26 'error_data' => $errorData,
27 );
28 }
29
30 return $result;
31 }
32
33 /**
34 * Function returns array of result expected from previous function.
35 *
36 * @return array
37 * API result array
38 */
39 function tag_getfields_expectedresult() {
40
41 $expectedResult = array(
42 'is_error' => 0,
43 'version' => 3,
44 'count' => 10,
45 'values' => array(
46 'id' => array(
47 'name' => 'id',
48 'type' => 1,
49 'title' => 'Tag ID',
50 'required' => TRUE,
51 'api.aliases' => array(
52 '0' => 'tag',
53 ),
54 ),
55 'name' => array(
56 'name' => 'name',
57 'type' => 2,
58 'title' => 'Tag Name',
59 'required' => TRUE,
60 'maxlength' => 64,
61 'size' => 30,
62 'api.required' => 1,
63 ),
64 'description' => array(
65 'name' => 'description',
66 'type' => 2,
67 'title' => 'Description',
68 'maxlength' => 255,
69 'size' => 45,
70 ),
71 'parent_id' => array(
72 'name' => 'parent_id',
73 'type' => 1,
74 'title' => 'Parent Tag',
75 'default' => 'NULL',
76 'FKClassName' => 'CRM_Core_DAO_Tag',
77 'FKApiName' => 'Tag',
78 ),
79 'is_selectable' => array(
80 'name' => 'is_selectable',
81 'type' => 16,
82 'title' => 'Display Tag?',
83 'default' => '1',
84 ),
85 'is_reserved' => array(
86 'name' => 'is_reserved',
87 'type' => 16,
88 'title' => 'Reserved',
89 ),
90 'is_tagset' => array(
91 'name' => 'is_tagset',
92 'type' => 16,
93 'title' => 'Tagset',
94 ),
95 'used_for' => array(
96 'name' => 'used_for',
97 'type' => 2,
98 'title' => 'Used For',
99 'maxlength' => 64,
100 'size' => 30,
101 'default' => 'NULL',
102 'html' => array(
103 'type' => 'Select',
104 ),
105 'pseudoconstant' => array(
106 'optionGroupName' => 'tag_used_for',
107 ),
108 'api.default' => 'civicrm_contact',
109 ),
110 'created_id' => array(
111 'name' => 'created_id',
112 'type' => 1,
113 'title' => 'Tag Created By',
114 'FKClassName' => 'CRM_Contact_DAO_Contact',
115 'FKApiName' => 'Contact',
116 ),
117 'created_date' => array(
118 'name' => 'created_date',
119 'type' => 12,
120 'title' => 'Tag Created Date',
121 ),
122 ),
123 );
124
125 return $expectedResult;
126 }
127
128 /*
129 * This example has been generated from the API test suite.
130 * The test that created it is called "testTagGetfields"
131 * and can be found at:
132 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TagTest.php
133 *
134 * You can see the outcome of the API tests at
135 * https://test.civicrm.org/job/CiviCRM-master-git/
136 *
137 * To Learn about the API read
138 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
139 *
140 * Browse the api on your own site with the api explorer
141 * http://MYSITE.ORG/path/to/civicrm/api
142 *
143 * Read more about testing here
144 * http://wiki.civicrm.org/confluence/display/CRM/Testing
145 *
146 * API Standards documentation:
147 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
148 */