Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / MailSettings / ChainedGetDelete.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the MailSettings.get API.
50fb255d 4 *
5c49fee0 5 * Demonstrates get + delete in the same call.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function mail_settings_get_example() {
11 $params = array(
12 'title' => 'MailSettings title',
13 'api.MailSettings.delete' => 1,
14 );
6a488035 15
50fb255d 16 try{
a828d7b8 17 $result = civicrm_api3('MailSettings', 'get', $params);
50fb255d 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;
6a488035
TO
32}
33
fb32de45 34/**
50fb255d 35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
6a488035 39 */
50fb255d 40function mail_settings_get_expectedresult() {
6a488035 41
53ca8fd7 42 $expectedResult = array(
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 2,
46 'values' => array(
53ca8fd7 47 '1' => array(
50fb255d 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,
6a488035 58 ),
50fb255d 59 ),
89bf81b4 60 '6' => array(
50fb255d 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,
6a488035 75 ),
50fb255d 76 ),
6a488035 77 ),
50fb255d 78 );
6a488035 79
fb32de45 80 return $expectedResult;
6a488035
TO
81}
82
a828d7b8 83/*
50fb255d 84* This example has been generated from the API test suite.
a828d7b8
CW
85* The test that created it is called "testGetMailSettingsChainDelete"
86* and can be found at:
69d79249 87* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.php
6a488035
TO
88*
89* You can see the outcome of the API tests at
69d79249 90* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
91*
92* To Learn about the API read
69d79249 93* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 94*
69d79249 95* Browse the api on your own site with the api explorer
41d4d31f 96* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
b259a4ab 103*/