Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-02-18-36-16
[civicrm-core.git] / api / v3 / examples / Tag / GetList.php
1 <?php
2 /**
3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8 /**
9 * Test Generated example of using tag getlist API.
10 *
11 * Demonstrates use of api.getlist for autocomplete and quicksearch applications
12 *
13 * @return array
14 * API result array
15 */
16 function tag_getlist_example() {
17 $params = array(
18 'input' => 'New Tag3',
19 'extra' => array(
20 '0' => 'used_for',
21 ),
22 );
23
24 try{
25 $result = civicrm_api3('tag', 'getlist', $params);
26 }
27 catch (CiviCRM_API3_Exception $e) {
28 // Handle error here.
29 $errorMessage = $e->getMessage();
30 $errorCode = $e->getErrorCode();
31 $errorData = $e->getExtraParams();
32 return array(
33 'error' => $errorMessage,
34 'error_code' => $errorCode,
35 'error_data' => $errorData,
36 );
37 }
38
39 return $result;
40 }
41
42 /**
43 * Function returns array of result expected from previous function.
44 *
45 * @return array
46 * API result array
47 */
48 function tag_getlist_expectedresult() {
49
50 $expectedResult = array(
51 'is_error' => 0,
52 'version' => 3,
53 'count' => 1,
54 'id' => 0,
55 'values' => array(
56 '0' => array(
57 'id' => '19',
58 'label' => 'New Tag3',
59 'description' => array(
60 '0' => 'This is description for Our New Tag ',
61 ),
62 'extra' => array(
63 'used_for' => 'civicrm_contact',
64 ),
65 ),
66 ),
67 'page_num' => 1,
68 'more_results' => '',
69 );
70
71 return $expectedResult;
72 }
73
74 /**
75 * This example has been generated from the API test suite.
76 * The test that created it is called
77 * testTagGetList
78 * and can be found in
79 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TagTest.php
80 *
81 * You can see the outcome of the API tests at
82 * https://test.civicrm.org/job/CiviCRM-master-git/
83 *
84 * To Learn about the API read
85 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
86 *
87 * Browse the api on your own site with the api explorer
88 * http://MYSITE.ORG/path/to/civicrm/api/explorer
89 *
90 * Read more about testing here
91 * http://wiki.civicrm.org/confluence/display/CRM/Testing
92 *
93 * API Standards documentation:
94 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
95 */