Merge pull request #4270 from eileenmcnaughton/CRM-15296-test-harness
[civicrm-core.git] / api / v3 / examples / ContributionPage / Create.php
1 <?php
2 /**
3 * Test Generated example of using contribution_page create API
4 * *
5 */
6 function contribution_page_create_example(){
7 $params = array(
8 'title' => 'Test Contribution Page',
9 'financial_type_id' => 1,
10 'currency' => 'NZD',
11 'goal_amount' => 34567,
12 'is_pay_later' => 1,
13 'is_monetary' => true,
14 );
15
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 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function
32 */
33 function contribution_page_create_expectedresult(){
34
35 $expectedResult = array(
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 1,
40 'values' => array(
41 '1' => array(
42 'id' => '1',
43 'title' => 'Test Contribution Page',
44 'intro_text' => '',
45 'financial_type_id' => '1',
46 'payment_processor' => '',
47 'is_credit_card_only' => '',
48 'is_monetary' => '1',
49 'is_recur' => '',
50 'is_confirm_enabled' => '',
51 'recur_frequency_unit' => '',
52 'is_recur_interval' => '',
53 'is_recur_installments' => '',
54 'is_pay_later' => '1',
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' => '',
77 'is_active' => '1',
78 'footer_text' => '',
79 'amount_block_is_active' => '',
80 'start_date' => '',
81 'end_date' => '',
82 'created_id' => '',
83 'created_date' => '',
84 'currency' => 'NZD',
85 'campaign_id' => '',
86 'is_share' => '',
87 ),
88 ),
89 );
90
91 return $expectedResult;
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
99 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
100 *
101 * You can see the outcome of the API tests at
102 * https://test.civicrm.org/job/CiviCRM-master-git/
103 *
104 * To Learn about the API read
105 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
106 *
107 * Browse the api on your own site with the api explorer
108 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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
115 */