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