Merge pull request #1271 from deepak-srivastava/revisions
[civicrm-core.git] / api / v3 / examples / MembershipUpdate.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' => 31,
9 'membership_type_id' => 28,
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' => 34,
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' => '31',
47 'membership_type_id' => '28',
48 'join_date' => '20090121000000',
49 'start_date' => '20090121000000',
50 'end_date' => '20091221000000',
51 'source' => 'Payment',
52 'status_id' => '34',
53 'is_override' => '1',
54 'owner_membership_id' => '',
55 'max_related' => '',
56 'is_test' => '',
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 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/MembershipTest.php
73 *
74 * You can see the outcome of the API tests at
75 * http://tests.dev.civicrm.org/trunk/results-api_v3
76 *
77 * To Learn about the API read
78 * http://book.civicrm.org/developer/current/techniques/api/
79 *
80 * and review the wiki at
81 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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 */