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