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