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 | */ |
6a488035 | 7 | |
50fb255d | 8 | /** |
9 | * Test Generated example of using pledge get API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function pledge_get_example() { | |
16 | $params = array( | |
17 | 'pledge_id' => 1, | |
18 | ); | |
6a488035 | 19 | |
50fb255d | 20 | try{ |
21 | $result = civicrm_api3('pledge', 'get', $params); | |
22 | } | |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // Handle error here. | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
28 | return array( | |
29 | 'error' => $errorMessage, | |
30 | 'error_code' => $errorCode, | |
31 | 'error_data' => $errorData, | |
32 | ); | |
33 | } | |
34 | ||
35 | return $result; | |
6a488035 TO |
36 | } |
37 | ||
fb32de45 | 38 | /** |
50fb255d | 39 | * Function returns array of result expected from previous function. |
40 | * | |
41 | * @return array | |
42 | * API result array | |
6a488035 | 43 | */ |
50fb255d | 44 | function pledge_get_expectedresult() { |
6a488035 | 45 | |
53ca8fd7 | 46 | $expectedResult = array( |
50fb255d | 47 | 'is_error' => 0, |
48 | 'version' => 3, | |
49 | 'count' => 1, | |
50 | 'id' => 1, | |
51 | 'values' => array( | |
53ca8fd7 | 52 | '1' => array( |
50fb255d | 53 | 'contact_id' => '5', |
54 | 'contact_type' => 'Individual', | |
55 | 'contact_sub_type' => '', | |
56 | 'sort_name' => 'Anderson, Anthony', | |
57 | 'display_name' => 'Mr. Anthony Anderson II', | |
58 | 'pledge_id' => '1', | |
59 | 'pledge_amount' => '100.00', | |
60 | 'pledge_create_date' => '2015-01-15 00:00:00', | |
61 | 'pledge_status' => 'Pending', | |
62 | 'pledge_total_paid' => '', | |
63 | 'pledge_next_pay_date' => '2015-01-17 00:00:00', | |
64 | 'pledge_next_pay_amount' => '20.00', | |
65 | 'pledge_outstanding_amount' => '', | |
66 | 'pledge_financial_type' => 'Donation', | |
67 | 'pledge_contribution_page_id' => '', | |
68 | 'pledge_frequency_interval' => '5', | |
69 | 'pledge_frequency_unit' => 'year', | |
70 | 'pledge_is_test' => 0, | |
71 | 'pledge_campaign_id' => '', | |
72 | 'pledge_currency' => 'USD', | |
73 | 'id' => '1', | |
74 | ), | |
6a488035 | 75 | ), |
50fb255d | 76 | ); |
6a488035 | 77 | |
fb32de45 | 78 | return $expectedResult; |
6a488035 TO |
79 | } |
80 | ||
50fb255d | 81 | /** |
82 | * This example has been generated from the API test suite. | |
83 | * The test that created it is called | |
84 | * testGetPledge | |
85 | * and can be found in | |
69d79249 | 86 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php |
6a488035 TO |
87 | * |
88 | * You can see the outcome of the API tests at | |
69d79249 | 89 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
90 | * |
91 | * To Learn about the API read | |
69d79249 | 92 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 93 | * |
69d79249 E |
94 | * Browse the api on your own site with the api explorer |
95 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
96 | * |
97 | * Read more about testing here | |
98 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
99 | * | |
100 | * API Standards documentation: | |
101 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 102 | */ |