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