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