Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using pledge create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function pledge_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 | 8 | 'contact_id' => 11, |
9f1b81e0 | 9 | 'pledge_create_date' => '20130803', |
10 | 'start_date' => '20130803', | |
11 | 'scheduled_date' => '20130805', | |
6a488035 TO |
12 | 'amount' => '100', |
13 | 'pledge_status_id' => '2', | |
14 | 'pledge_financial_type_id' => '1', | |
15 | 'pledge_original_installment_amount' => 20, | |
16 | 'frequency_interval' => 5, | |
17 | 'frequency_unit' => 'year', | |
18 | 'frequency_day' => 15, | |
19 | 'installments' => 5, | |
20 | 'sequential' => 1, | |
6a488035 TO |
21 | ); |
22 | ||
fb32de45 | 23 | try{ |
24 | $result = civicrm_api3('pledge', 'create', $params); | |
25 | } | |
26 | catch (CiviCRM_API3_Exception $e) { | |
27 | // handle error here | |
28 | $errorMessage = $e->getMessage(); | |
29 | $errorCode = $e->getErrorCode(); | |
30 | $errorData = $e->getExtraParams(); | |
31 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
32 | } | |
6a488035 | 33 | |
fb32de45 | 34 | return $result; |
6a488035 TO |
35 | } |
36 | ||
fb32de45 | 37 | /** |
6a488035 TO |
38 | * Function returns array of result expected from previous function |
39 | */ | |
40 | function pledge_create_expectedresult(){ | |
41 | ||
53ca8fd7 | 42 | $expectedResult = array( |
6a488035 TO |
43 | 'is_error' => 0, |
44 | 'version' => 3, | |
45 | 'count' => 1, | |
46 | 'id' => 1, | |
53ca8fd7 | 47 | 'values' => array( |
48 | '0' => array( | |
6a488035 TO |
49 | 'id' => '1', |
50 | 'contact_id' => '11', | |
51 | 'financial_type_id' => '1', | |
52 | 'contribution_page_id' => '', | |
53 | 'amount' => '100', | |
54 | 'original_installment_amount' => '20', | |
55 | 'currency' => 'USD', | |
56 | 'frequency_unit' => 'year', | |
57 | 'frequency_interval' => '5', | |
58 | 'frequency_day' => '15', | |
59 | 'installments' => '5', | |
9f1b81e0 | 60 | 'start_date' => '2013-07-29 00:00:00', |
fb32de45 | 61 | 'create_date' => '20120130621222105', |
6a488035 | 62 | 'acknowledge_date' => '', |
9f1b81e0 | 63 | 'modified_date' => '', |
6a488035 TO |
64 | 'cancel_date' => '', |
65 | 'end_date' => '', | |
66 | 'honor_contact_id' => '', | |
67 | 'honor_type_id' => '', | |
68 | 'max_reminders' => '', | |
69 | 'initial_reminder_day' => '', | |
70 | 'additional_reminder_day' => '', | |
71 | 'status_id' => '2', | |
72 | 'is_test' => '', | |
73 | 'campaign_id' => '', | |
74 | ), | |
75 | ), | |
76 | ); | |
77 | ||
fb32de45 | 78 | return $expectedResult; |
6a488035 TO |
79 | } |
80 | ||
81 | ||
82 | /* | |
83 | * This example has been generated from the API test suite. The test that created it is called | |
84 | * | |
85 | * testCreatePledge and can be found in | |
86 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/PledgeTest.php | |
87 | * | |
88 | * You can see the outcome of the API tests at | |
89 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
90 | * | |
91 | * To Learn about the API read | |
92 | * http://book.civicrm.org/developer/current/techniques/api/ | |
93 | * | |
94 | * and review the wiki at | |
95 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
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 | |
102 | */ |