3 * Test Generated example demonstrating the Membership.create API.
8 function membership_create_example() {
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',
18 'custom_1' => 'custom string',
22 $result = civicrm_api3('Membership', 'create', $params);
24 catch (CiviCRM_API3_Exception
$e) {
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
31 'error_message' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
41 * Function returns array of result expected from previous function.
46 function membership_create_expectedresult() {
48 $expectedResult = array(
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',
64 'owner_membership_id' => '',
68 'contribution_recur_id' => '',
74 return $expectedResult;
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
83 * You can see the outcome of the API tests at
84 * https://test.civicrm.org/job/CiviCRM-master-git/
86 * To Learn about the API read
87 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
89 * Browse the api on your own site with the api explorer
90 * http://MYSITE.ORG/path/to/civicrm/api
92 * Read more about testing here
93 * http://wiki.civicrm.org/confluence/display/CRM/Testing
95 * API Standards documentation:
96 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards