Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-04-21-08-12-12
[civicrm-core.git] / api / v3 / examples / MailSettings / ChainedGetDelete.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using mail_settings get API
4 * demonstrates get + delete in the same call *
6a488035
TO
5 */
6function mail_settings_get_example(){
53ca8fd7 7$params = array(
6a488035
TO
8 'title' => 'MailSettings title',
9 'api.MailSettings.delete' => 1,
10);
11
fb32de45 12try{
13 $result = civicrm_api3('mail_settings', 'get', $params);
14}
15catch (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}
6a488035 22
fb32de45 23return $result;
6a488035
TO
24}
25
fb32de45 26/**
6a488035
TO
27 * Function returns array of result expected from previous function
28 */
29function mail_settings_get_expectedresult(){
30
53ca8fd7 31 $expectedResult = array(
6a488035
TO
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 2,
53ca8fd7 35 'values' => array(
36 '1' => array(
6a488035
TO
37 'id' => '1',
38 'domain_id' => '1',
39 'name' => 'default',
40 'is_default' => '1',
41 'domain' => 'EXAMPLE.ORG',
53ca8fd7 42 'api.MailSettings.delete' => array(
6a488035
TO
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'values' => 1,
47 ),
48 ),
53ca8fd7 49 '3' => array(
6a488035
TO
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,
53ca8fd7 59 'api.MailSettings.delete' => array(
6a488035
TO
60 'is_error' => 0,
61 'version' => 3,
62 'count' => 1,
63 'values' => 1,
64 ),
65 ),
66 ),
67);
68
fb32de45 69 return $expectedResult;
6a488035
TO
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
69d79249 77* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.php
6a488035
TO
78*
79* You can see the outcome of the API tests at
69d79249 80* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
81*
82* To Learn about the API read
69d79249 83* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 84*
69d79249
E
85* Browse the api on your own site with the api explorer
86* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
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
b259a4ab 93*/