Merge pull request #4246 from crusonweb/CRM-15310
[civicrm-core.git] / api / v3 / examples / MailSettings / Get.php
... / ...
CommitLineData
1<?php
2/**
3 * Test Generated example of using mail_settings get API
4 * *
5 */
6function mail_settings_get_example(){
7$params = array(
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',
15 'is_default' => 1,
16);
17
18try{
19 $result = civicrm_api3('mail_settings', 'get', $params);
20}
21catch (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}
28
29return $result;
30}
31
32/**
33 * Function returns array of result expected from previous function
34 */
35function mail_settings_get_expectedresult(){
36
37 $expectedResult = array(
38 'is_error' => 0,
39 'version' => 3,
40 'count' => 1,
41 'id' => 4,
42 'values' => array(
43 '4' => array(
44 'id' => '4',
45 'domain_id' => '1',
46 'name' => 'my mail setting',
47 'is_default' => '1',
48 'domain' => 'setting.com',
49 'server' => 'localhost',
50 'username' => 'sue',
51 'password' => 'pass',
52 'is_ssl' => 0,
53 ),
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* testGetMailSettings and can be found in
65* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.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*/