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