Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-09-11-44-07
[civicrm-core.git] / api / v3 / examples / Membership / Update.php
1 <?php
2 /**
3 * Test Generated example of using membership update API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function membership_update_example() {
10 $params = array(
11 'contact_id' => 106,
12 'membership_type_id' => 65,
13 'join_date' => '2009-01-21',
14 'start_date' => '2009-01-21',
15 'end_date' => '2009-12-21',
16 'source' => 'Payment',
17 'is_override' => 1,
18 'status_id' => 39,
19 'custom_1' => 'custom string',
20 );
21
22 try{
23 $result = civicrm_api3('membership', 'update', $params);
24 }
25 catch (CiviCRM_API3_Exception $e) {
26 // Handle error here.
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
30 return array(
31 'error' => $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_update_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' => '106',
57 'membership_type_id' => '65',
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' => '39',
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
80 * testUpdateWithCustom
81 * and can be found in
82 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php
83 *
84 * You can see the outcome of the API tests at
85 * https://test.civicrm.org/job/CiviCRM-master-git/
86 *
87 * To Learn about the API read
88 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
89 *
90 * Browse the api on your own site with the api explorer
91 * http://MYSITE.ORG/path/to/civicrm/api
92 *
93 * Read more about testing here
94 * http://wiki.civicrm.org/confluence/display/CRM/Testing
95 *
96 * API Standards documentation:
97 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
98 */