| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example demonstrating the Contact.getactions API. |
| 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(); |
| 12 | |
| 13 | try{ |
| 14 | $result = civicrm_api3('Contact', 'getactions', $params); |
| 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( |
| 22 | 'is_error' => 1, |
| 23 | 'error_message' => $errorMessage, |
| 24 | 'error_code' => $errorCode, |
| 25 | 'error_data' => $errorData, |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | return $result; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Function returns array of result expected from previous function. |
| 34 | * |
| 35 | * @return array |
| 36 | * API result array |
| 37 | */ |
| 38 | function contact_getactions_expectedresult() { |
| 39 | |
| 40 | $expectedResult = array( |
| 41 | 'is_error' => 0, |
| 42 | 'version' => 3, |
| 43 | 'count' => 25, |
| 44 | 'values' => array( |
| 45 | '0' => 'create', |
| 46 | '1' => 'delete', |
| 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', |
| 70 | ), |
| 71 | 'deprecated' => array( |
| 72 | 'getquick' => 'The "getquick" action is deprecated in favor of "getlist".', |
| 73 | 'setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.', |
| 74 | 'update' => 'The "update" action is deprecated. Use "create" with an id instead.', |
| 75 | ), |
| 76 | ); |
| 77 | |
| 78 | return $expectedResult; |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * This example has been generated from the API test suite. |
| 83 | * The test that created it is called "testGetActions" |
| 84 | * and can be found at: |
| 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 |
| 94 | * http://MYSITE.ORG/path/to/civicrm/api |
| 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 | */ |