Commit | Line | Data |
---|---|---|
fb32de45 | 1 | <?php |
2 | /** | |
3 | * Test Generated example of using tag getfields API | |
4 | * demonstrate use of getfields to interogate 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 | 'required' => true, | |
39 | 'api.aliases' => array( | |
40 | '0' => 'tag', | |
41 | ), | |
42 | ), | |
43 | 'name' => array( | |
44 | 'name' => 'name', | |
45 | 'type' => 2, | |
46 | 'title' => 'Name', | |
47 | 'required' => true, | |
48 | 'maxlength' => 64, | |
49 | 'size' => 30, | |
50 | 'api.required' => 1, | |
51 | ), | |
52 | 'description' => array( | |
53 | 'name' => 'description', | |
54 | 'type' => 2, | |
55 | 'title' => 'Description', | |
56 | 'maxlength' => 255, | |
57 | 'size' => 45, | |
58 | ), | |
59 | 'parent_id' => array( | |
60 | 'name' => 'parent_id', | |
61 | 'type' => 1, | |
b259a4ab | 62 | 'default' => 'NULL', |
fb32de45 | 63 | 'FKClassName' => 'CRM_Core_DAO_Tag', |
64 | ), | |
65 | 'is_selectable' => array( | |
66 | 'name' => 'is_selectable', | |
67 | 'type' => 16, | |
b259a4ab | 68 | 'default' => '1', |
fb32de45 | 69 | ), |
70 | 'is_reserved' => array( | |
71 | 'name' => 'is_reserved', | |
72 | 'type' => 16, | |
73 | ), | |
74 | 'is_tagset' => array( | |
75 | 'name' => 'is_tagset', | |
76 | 'type' => 16, | |
77 | ), | |
78 | 'used_for' => array( | |
79 | 'name' => 'used_for', | |
80 | 'type' => 2, | |
81 | 'title' => 'Used For', | |
82 | 'maxlength' => 64, | |
83 | 'size' => 30, | |
b259a4ab | 84 | 'default' => 'NULL', |
fb32de45 | 85 | 'api.default' => 'civicrm_contact', |
86 | ), | |
87 | 'created_id' => array( | |
88 | 'name' => 'created_id', | |
89 | 'type' => 1, | |
90 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
91 | ), | |
92 | 'created_date' => array( | |
93 | 'name' => 'created_date', | |
94 | 'type' => 12, | |
95 | 'title' => 'Tag Created Date', | |
96 | ), | |
97 | ), | |
98 | ); | |
99 | ||
100 | return $expectedResult; | |
101 | } | |
102 | ||
103 | ||
104 | /* | |
105 | * This example has been generated from the API test suite. The test that created it is called | |
106 | * | |
107 | * testTagGetfields and can be found in | |
69d79249 | 108 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TagTest.php |
fb32de45 | 109 | * |
110 | * You can see the outcome of the API tests at | |
69d79249 | 111 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
fb32de45 | 112 | * |
113 | * To Learn about the API read | |
69d79249 | 114 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
fb32de45 | 115 | * |
69d79249 E |
116 | * Browse the api on your own site with the api explorer |
117 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
fb32de45 | 118 | * |
119 | * Read more about testing here | |
120 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
121 | * | |
122 | * API Standards documentation: | |
123 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 124 | */ |