Merge branch 4.5 into master
[civicrm-core.git] / api / v3 / examples / Contact / GetActions.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 contact getactions API.
10 *
11 * Getting the available actions for an entity.
12 *
13 * @return array
14 * API result array
15 */
16 function contact_getactions_example() {
17 $params = array();
18
19 try{
20 $result = civicrm_api3('contact', 'getactions', $params);
21 }
22 catch (CiviCRM_API3_Exception $e) {
23 // Handle error here.
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array(
28 'error' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
42 */
43 function contact_getactions_expectedresult() {
44
45 $expectedResult = array(
46 'is_error' => 0,
47 'version' => 3,
48 'count' => 17,
49 'values' => array(
50 '0' => 'create',
51 '1' => 'delete',
52 '2' => 'get',
53 '3' => 'getactions',
54 '4' => 'getcount',
55 '5' => 'getfields',
56 '6' => 'getlist',
57 '7' => 'getoptions',
58 '8' => 'getquick',
59 '9' => 'getrefcount',
60 '10' => 'getsingle',
61 '11' => 'getvalue',
62 '12' => 'merge',
63 '13' => 'proximity',
64 '14' => 'replace',
65 '15' => 'setvalue',
66 '16' => 'update',
67 ),
68 'deprecated' => array(
69 'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
70 'update' => 'The "update" action is deprecated. Use "create" with an id instead.',
71 ),
72 );
73
74 return $expectedResult;
75 }
76
77 /**
78 * This example has been generated from the API test suite.
79 * The test that created it is called
80 * testGetActions
81 * and can be found in
82 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
83 *
84 * You can see the outcome of the API tests at
85 * https://test.civicrm.org/job/CiviCRM-master-git/
86 *
87 * To Learn about the API read
88 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
89 *
90 * Browse the api on your own site with the api explorer
91 * http://MYSITE.ORG/path/to/civicrm/api/explorer
92 *
93 * Read more about testing here
94 * http://wiki.civicrm.org/confluence/display/CRM/Testing
95 *
96 * API Standards documentation:
97 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
98 */