| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example demonstrating the MailSettings.get API. |
| 4 | * |
| 5 | * Demonstrates get + delete in the same call. |
| 6 | * |
| 7 | * @return array |
| 8 | * API result array |
| 9 | */ |
| 10 | function mail_settings_get_example() { |
| 11 | $params = array( |
| 12 | 'title' => 'MailSettings title', |
| 13 | 'api.MailSettings.delete' => 1, |
| 14 | ); |
| 15 | |
| 16 | try{ |
| 17 | $result = civicrm_api3('MailSettings', 'get', $params); |
| 18 | } |
| 19 | catch (CiviCRM_API3_Exception $e) { |
| 20 | // Handle error here. |
| 21 | $errorMessage = $e->getMessage(); |
| 22 | $errorCode = $e->getErrorCode(); |
| 23 | $errorData = $e->getExtraParams(); |
| 24 | return array( |
| 25 | 'error' => $errorMessage, |
| 26 | 'error_code' => $errorCode, |
| 27 | 'error_data' => $errorData, |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | return $result; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Function returns array of result expected from previous function. |
| 36 | * |
| 37 | * @return array |
| 38 | * API result array |
| 39 | */ |
| 40 | function mail_settings_get_expectedresult() { |
| 41 | |
| 42 | $expectedResult = array( |
| 43 | 'is_error' => 0, |
| 44 | 'version' => 3, |
| 45 | 'count' => 2, |
| 46 | 'values' => array( |
| 47 | '1' => array( |
| 48 | 'id' => '1', |
| 49 | 'domain_id' => '1', |
| 50 | 'name' => 'default', |
| 51 | 'is_default' => 0, |
| 52 | 'domain' => 'EXAMPLE.ORG', |
| 53 | 'api.MailSettings.delete' => array( |
| 54 | 'is_error' => 0, |
| 55 | 'version' => 3, |
| 56 | 'count' => 1, |
| 57 | 'values' => 1, |
| 58 | ), |
| 59 | ), |
| 60 | '6' => array( |
| 61 | 'id' => '6', |
| 62 | 'domain_id' => '1', |
| 63 | 'name' => 'my mail setting', |
| 64 | 'is_default' => '1', |
| 65 | 'domain' => 'setting.com', |
| 66 | 'server' => 'localhost', |
| 67 | 'username' => 'sue', |
| 68 | 'password' => 'pass', |
| 69 | 'is_ssl' => 0, |
| 70 | 'api.MailSettings.delete' => array( |
| 71 | 'is_error' => 0, |
| 72 | 'version' => 3, |
| 73 | 'count' => 1, |
| 74 | 'values' => 1, |
| 75 | ), |
| 76 | ), |
| 77 | ), |
| 78 | ); |
| 79 | |
| 80 | return $expectedResult; |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * This example has been generated from the API test suite. |
| 85 | * The test that created it is called "testGetMailSettingsChainDelete" |
| 86 | * and can be found at: |
| 87 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.php |
| 88 | * |
| 89 | * You can see the outcome of the API tests at |
| 90 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
| 91 | * |
| 92 | * To Learn about the API read |
| 93 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
| 94 | * |
| 95 | * Browse the api on your own site with the api explorer |
| 96 | * http://MYSITE.ORG/path/to/civicrm/api |
| 97 | * |
| 98 | * Read more about testing here |
| 99 | * http://wiki.civicrm.org/confluence/display/CRM/Testing |
| 100 | * |
| 101 | * API Standards documentation: |
| 102 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards |
| 103 | */ |