Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
50fb255d | 3 | * @file |
4 | * Test Generated API Example. | |
5 | * See bottom of this file for more detail. | |
6a488035 | 6 | */ |
50fb255d | 7 | |
8 | /** | |
9 | * Test Generated example of using setting Get API. | |
10 | * | |
11 | * shows getting a variable for specified domains | |
12 | * | |
13 | * @return array | |
14 | * API result array | |
15 | */ | |
16 | function setting_get_example() { | |
17 | $params = array( | |
18 | 'domain_id' => array( | |
6a488035 TO |
19 | '0' => 1, |
20 | '1' => 2, | |
21 | ), | |
50fb255d | 22 | 'return' => array( |
6a488035 TO |
23 | '0' => 'uniq_email_per_site', |
24 | ), | |
50fb255d | 25 | ); |
6a488035 | 26 | |
50fb255d | 27 | try{ |
28 | $result = civicrm_api3('setting', 'Get', $params); | |
29 | } | |
30 | catch (CiviCRM_API3_Exception $e) { | |
31 | // Handle error here. | |
32 | $errorMessage = $e->getMessage(); | |
33 | $errorCode = $e->getErrorCode(); | |
34 | $errorData = $e->getExtraParams(); | |
35 | return array( | |
36 | 'error' => $errorMessage, | |
37 | 'error_code' => $errorCode, | |
38 | 'error_data' => $errorData, | |
39 | ); | |
40 | } | |
6a488035 | 41 | |
50fb255d | 42 | return $result; |
6a488035 TO |
43 | } |
44 | ||
fb32de45 | 45 | /** |
50fb255d | 46 | * Function returns array of result expected from previous function. |
47 | * | |
48 | * @return array | |
49 | * API result array | |
6a488035 | 50 | */ |
50fb255d | 51 | function setting_get_expectedresult() { |
6a488035 | 52 | |
53ca8fd7 | 53 | $expectedResult = array( |
50fb255d | 54 | 'is_error' => 0, |
55 | 'version' => 3, | |
56 | 'count' => 2, | |
57 | 'values' => array( | |
53ca8fd7 | 58 | '1' => array( |
50fb255d | 59 | 'uniq_email_per_site' => 0, |
60 | ), | |
53ca8fd7 | 61 | '2' => array( |
50fb255d | 62 | 'uniq_email_per_site' => '1', |
63 | ), | |
6a488035 | 64 | ), |
50fb255d | 65 | ); |
6a488035 | 66 | |
fb32de45 | 67 | return $expectedResult; |
6a488035 TO |
68 | } |
69 | ||
50fb255d | 70 | /** |
71 | * This example has been generated from the API test suite. | |
72 | * The test that created it is called | |
73 | * testCreateSettingMultipleDomains | |
74 | * and can be found in | |
69d79249 | 75 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SettingTest.php |
6a488035 TO |
76 | * |
77 | * You can see the outcome of the API tests at | |
69d79249 | 78 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
79 | * |
80 | * To Learn about the API read | |
69d79249 | 81 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 82 | * |
69d79249 E |
83 | * Browse the api on your own site with the api explorer |
84 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
85 | * |
86 | * Read more about testing here | |
87 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
88 | * | |
89 | * API Standards documentation: | |
90 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
4ed37178 | 91 | */ |