Merge pull request #13281 from yashodha/campaign
[civicrm-core.git] / api / v3 / examples / Setting / Revert.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Setting.revert API.
50fb255d 4 *
5c49fee0 5 * Demonstrates reverting a parameter to default value.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function setting_revert_example() {
11 $params = array(
12 'name' => 'address_format',
13 );
6a488035 14
50fb255d 15 try{
a828d7b8 16 $result = civicrm_api3('Setting', 'revert', $params);
50fb255d 17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
1d8ee3d6 24 'is_error' => 1,
25 'error_message' => $errorMessage,
50fb255d 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 setting_revert_expectedresult() {
6a488035 41
53ca8fd7 42 $expectedResult = array(
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 5,
46 'id' => 1,
47 'values' => array(
6a488035
TO
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 1,
53ca8fd7 52 'values' => array(
50fb255d 53 '1' => array(
54 'address_format' => '{contact.address_name}
6a488035
TO
55{contact.street_address}
56{contact.supplemental_address_1}
57{contact.supplemental_address_2}
207f62c6 58{contact.supplemental_address_3}
6a488035
TO
59{contact.city}{, }{contact.state_province}{ }{contact.postal_code}
60{contact.country}',
6a488035 61 ),
50fb255d 62 ),
6a488035 63 ),
50fb255d 64 );
6a488035 65
fb32de45 66 return $expectedResult;
6a488035
TO
67}
68
a828d7b8 69/*
50fb255d 70* This example has been generated from the API test suite.
a828d7b8
CW
71* The test that created it is called "testRevert"
72* and can be found at:
69d79249 73* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SettingTest.php
6a488035
TO
74*
75* You can see the outcome of the API tests at
69d79249 76* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
77*
78* To Learn about the API read
69d79249 79* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 80*
69d79249 81* Browse the api on your own site with the api explorer
41d4d31f 82* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
83*
84* Read more about testing here
85* http://wiki.civicrm.org/confluence/display/CRM/Testing
86*
87* API Standards documentation:
88* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
4ed37178 89*/