Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the PledgePayment.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function pledge_payment_create_example() { | |
cf8f0fff | 9 | $params = [ |
50fb255d | 10 | 'contact_id' => 1, |
11 | 'pledge_id' => 1, | |
12 | 'contribution_id' => 1, | |
13 | 'status_id' => 1, | |
14 | 'actual_amount' => 20, | |
cf8f0fff | 15 | ]; |
6a488035 | 16 | |
50fb255d | 17 | try{ |
a828d7b8 | 18 | $result = civicrm_api3('PledgePayment', 'create', $params); |
50fb255d | 19 | } |
20 | catch (CiviCRM_API3_Exception $e) { | |
21 | // Handle error here. | |
22 | $errorMessage = $e->getMessage(); | |
23 | $errorCode = $e->getErrorCode(); | |
24 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 25 | return [ |
1d8ee3d6 | 26 | 'is_error' => 1, |
27 | 'error_message' => $errorMessage, | |
50fb255d | 28 | 'error_code' => $errorCode, |
29 | 'error_data' => $errorData, | |
cf8f0fff | 30 | ]; |
50fb255d | 31 | } |
32 | ||
33 | return $result; | |
6a488035 TO |
34 | } |
35 | ||
fb32de45 | 36 | /** |
50fb255d | 37 | * Function returns array of result expected from previous function. |
38 | * | |
39 | * @return array | |
40 | * API result array | |
6a488035 | 41 | */ |
50fb255d | 42 | function pledge_payment_create_expectedresult() { |
6a488035 | 43 | |
cf8f0fff | 44 | $expectedResult = [ |
50fb255d | 45 | 'is_error' => 0, |
46 | 'version' => 3, | |
47 | 'count' => 1, | |
48 | 'id' => 1, | |
cf8f0fff CW |
49 | 'values' => [ |
50 | '1' => [ | |
50fb255d | 51 | 'id' => '1', |
52 | 'pledge_id' => '1', | |
53 | 'contribution_id' => '1', | |
54 | 'scheduled_amount' => '', | |
55 | 'actual_amount' => '20', | |
56 | 'currency' => 'USD', | |
57 | 'scheduled_date' => '', | |
58 | 'reminder_date' => '', | |
59 | 'reminder_count' => '', | |
60 | 'status_id' => '1', | |
cf8f0fff CW |
61 | ], |
62 | ], | |
63 | ]; | |
6a488035 | 64 | |
fb32de45 | 65 | return $expectedResult; |
6a488035 TO |
66 | } |
67 | ||
a828d7b8 | 68 | /* |
50fb255d | 69 | * This example has been generated from the API test suite. |
a828d7b8 CW |
70 | * The test that created it is called "testCreatePledgePayment" |
71 | * and can be found at: | |
69d79249 | 72 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgePaymentTest.php |
6a488035 TO |
73 | * |
74 | * You can see the outcome of the API tests at | |
69d79249 | 75 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
76 | * |
77 | * To Learn about the API read | |
69d79249 | 78 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 79 | * |
69d79249 | 80 | * Browse the api on your own site with the api explorer |
41d4d31f | 81 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
82 | * |
83 | * Read more about testing here | |
84 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
85 | * | |
86 | * API Standards documentation: | |
87 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 88 | */ |