test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / ContributionRecurCreate.php
1 <?php
2 /**
3 * Test Generated example of using contribution_recur create API
4 * *
5 */
6 function contribution_recur_create_example(){
7 $params = array(
8 'contact_id' => 3,
9 'installments' => '12',
10 'frequency_interval' => '1',
11 'amount' => '500',
12 'contribution_status_id' => 1,
13 'start_date' => '2012-01-01 00:00:00',
14 'currency' => 'USD',
15 'frequency_unit' => 'day',
16 );
17
18 try{
19 $result = civicrm_api3('contribution_recur', 'create', $params);
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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function
34 */
35 function contribution_recur_create_expectedresult(){
36
37 $expectedResult = array(
38 'is_error' => 0,
39 'version' => 3,
40 'count' => 1,
41 'id' => 1,
42 'values' => array(
43 '1' => array(
44 'id' => '1',
45 'contact_id' => '3',
46 'amount' => '500',
47 'currency' => 'USD',
48 'frequency_unit' => 'day',
49 'frequency_interval' => '1',
50 'installments' => '12',
51 'start_date' => '2013-07-29 00:00:00',
52 'create_date' => '20120130621222105',
53 'modified_date' => '',
54 'cancel_date' => '',
55 'end_date' => '',
56 'processor_id' => '',
57 'trxn_id' => '',
58 'invoice_id' => '',
59 'contribution_status_id' => '1',
60 'is_test' => '',
61 'cycle_day' => '',
62 'next_sched_contribution' => '',
63 'failure_count' => '',
64 'failure_retry_date' => '',
65 'auto_renew' => '',
66 'payment_processor_id' => '',
67 'financial_type_id' => '',
68 'payment_instrument_id' => '',
69 'campaign_id' => '',
70 'is_email_receipt' => '',
71 ),
72 ),
73 );
74
75 return $expectedResult;
76 }
77
78
79 /*
80 * This example has been generated from the API test suite. The test that created it is called
81 *
82 * testCreateContributionRecur and can be found in
83 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContributionRecurTest.php
84 *
85 * You can see the outcome of the API tests at
86 * http://tests.dev.civicrm.org/trunk/results-api_v3
87 *
88 * To Learn about the API read
89 * http://book.civicrm.org/developer/current/techniques/api/
90 *
91 * and review the wiki at
92 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
93 *
94 * Read more about testing here
95 * http://wiki.civicrm.org/confluence/display/CRM/Testing
96 *
97 * API Standards documentation:
98 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
99 */