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