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