Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the ContributionPage.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function contribution_page_create_example() { | |
9 | $params = array( | |
10 | 'title' => 'Test Contribution Page', | |
11 | 'financial_type_id' => 1, | |
12 | 'currency' => 'NZD', | |
13 | 'goal_amount' => 34567, | |
14 | 'is_pay_later' => 1, | |
15 | 'is_monetary' => TRUE, | |
16 | ); | |
6a488035 | 17 | |
50fb255d | 18 | try{ |
a828d7b8 | 19 | $result = civicrm_api3('ContributionPage', 'create', $params); |
50fb255d | 20 | } |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // Handle error here. | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
26 | return array( | |
27 | 'error' => $errorMessage, | |
28 | 'error_code' => $errorCode, | |
29 | 'error_data' => $errorData, | |
30 | ); | |
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 contribution_page_create_expectedresult() { |
6a488035 | 43 | |
edb0d67a | 44 | $expectedResult = array( |
50fb255d | 45 | 'is_error' => 0, |
46 | 'version' => 3, | |
47 | 'count' => 1, | |
48 | 'id' => 1, | |
49 | 'values' => array( | |
edb0d67a | 50 | '1' => array( |
50fb255d | 51 | 'id' => '1', |
52 | 'title' => 'Test Contribution Page', | |
53 | 'intro_text' => '', | |
54 | 'financial_type_id' => '1', | |
55 | 'payment_processor' => '', | |
56 | 'is_credit_card_only' => '', | |
57 | 'is_monetary' => '1', | |
58 | 'is_recur' => '', | |
59 | 'is_confirm_enabled' => '', | |
60 | 'recur_frequency_unit' => '', | |
61 | 'is_recur_interval' => '', | |
62 | 'is_recur_installments' => '', | |
63 | 'is_pay_later' => '1', | |
64 | 'pay_later_text' => '', | |
65 | 'pay_later_receipt' => '', | |
66 | 'is_partial_payment' => '', | |
67 | 'initial_amount_label' => '', | |
68 | 'initial_amount_help_text' => '', | |
69 | 'min_initial_amount' => '', | |
70 | 'is_allow_other_amount' => '', | |
71 | 'default_amount_id' => '', | |
72 | 'min_amount' => '', | |
73 | 'max_amount' => '', | |
74 | 'goal_amount' => '34567', | |
75 | 'thankyou_title' => '', | |
76 | 'thankyou_text' => '', | |
77 | 'thankyou_footer' => '', | |
78 | 'is_for_organization' => '', | |
79 | 'for_organization' => '', | |
80 | 'is_email_receipt' => '', | |
81 | 'receipt_from_name' => '', | |
82 | 'receipt_from_email' => '', | |
83 | 'cc_receipt' => '', | |
84 | 'bcc_receipt' => '', | |
85 | 'receipt_text' => '', | |
86 | 'is_active' => '1', | |
87 | 'footer_text' => '', | |
88 | 'amount_block_is_active' => '', | |
89 | 'start_date' => '', | |
90 | 'end_date' => '', | |
91 | 'created_id' => '', | |
92 | 'created_date' => '', | |
93 | 'currency' => 'NZD', | |
94 | 'campaign_id' => '', | |
95 | 'is_share' => '', | |
96 | 'is_billing_required' => '', | |
97 | ), | |
6a488035 | 98 | ), |
50fb255d | 99 | ); |
6a488035 | 100 | |
fb32de45 | 101 | return $expectedResult; |
6a488035 TO |
102 | } |
103 | ||
a828d7b8 | 104 | /* |
50fb255d | 105 | * This example has been generated from the API test suite. |
a828d7b8 CW |
106 | * The test that created it is called "testCreateContributionPage" |
107 | * and can be found at: | |
69d79249 | 108 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php |
6a488035 TO |
109 | * |
110 | * You can see the outcome of the API tests at | |
69d79249 | 111 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
112 | * |
113 | * To Learn about the API read | |
69d79249 | 114 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 115 | * |
69d79249 | 116 | * Browse the api on your own site with the api explorer |
41d4d31f | 117 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
118 | * |
119 | * Read more about testing here | |
120 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
121 | * | |
122 | * API Standards documentation: | |
123 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 124 | */ |