Merge pull request #13908 from eileenmcnaughton/report_filter
[civicrm-core.git] / api / v3 / examples / Membership / UpdateCustomData.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Membership.create API.
4 *
5 * @return array
6 * API result array
7 */
8 function membership_create_example() {
9 $params = array(
10 'contact_id' => 112,
11 'membership_type_id' => 69,
12 'join_date' => '2009-01-21',
13 'start_date' => '2009-01-21',
14 'end_date' => '2009-12-21',
15 'source' => 'Payment',
16 'is_override' => 1,
17 'status_id' => 41,
18 'custom_1' => 'custom string',
19 );
20
21 try{
22 $result = civicrm_api3('Membership', 'create', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // Handle error here.
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array(
30 'is_error' => 1,
31 'error_message' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
38 }
39
40 /**
41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
45 */
46 function membership_create_expectedresult() {
47
48 $expectedResult = array(
49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 1,
53 'values' => array(
54 '1' => array(
55 'id' => '1',
56 'contact_id' => '112',
57 'membership_type_id' => '69',
58 'join_date' => '20090121000000',
59 'start_date' => '2013-07-29 00:00:00',
60 'end_date' => '2013-08-04 00:00:00',
61 'source' => 'Payment',
62 'status_id' => '41',
63 'is_override' => '1',
64 'owner_membership_id' => '',
65 'max_related' => '',
66 'is_test' => 0,
67 'is_pay_later' => '',
68 'contribution_recur_id' => '',
69 'campaign_id' => '',
70 ),
71 ),
72 );
73
74 return $expectedResult;
75 }
76
77 /*
78 * This example has been generated from the API test suite.
79 * The test that created it is called "testUpdateWithCustom"
80 * and can be found at:
81 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php
82 *
83 * You can see the outcome of the API tests at
84 * https://test.civicrm.org/job/CiviCRM-master-git/
85 *
86 * To Learn about the API read
87 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
88 *
89 * Browse the api on your own site with the api explorer
90 * http://MYSITE.ORG/path/to/civicrm/api
91 *
92 * Read more about testing here
93 * http://wiki.civicrm.org/confluence/display/CRM/Testing
94 *
95 * API Standards documentation:
96 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
97 */