3 * Test Generated example demonstrating the MembershipType.create API.
8 function membership_type_create_example() {
10 'name' => '40+ Membership',
11 'description' => 'people above 40 are given health instructions',
12 'member_of_contact_id' => 13,
13 'financial_type_id' => 1,
15 'minimum_fee' => '200',
16 'duration_unit' => 'month',
17 'duration_interval' => '10',
18 'period_type' => 'rolling',
19 'visibility' => 'public',
23 $result = civicrm_api3('MembershipType', 'create', $params);
25 catch (CiviCRM_API3_Exception
$e) {
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
41 * Function returns array of result expected from previous function.
46 function membership_type_create_expectedresult() {
48 $expectedResult = array(
57 'name' => '40+ Membership',
58 'description' => 'people above 40 are given health instructions',
59 'member_of_contact_id' => '13',
60 'financial_type_id' => '1',
61 'minimum_fee' => '200',
62 'duration_unit' => 'month',
63 'duration_interval' => '10',
64 'period_type' => 'rolling',
65 'fixed_period_start_day' => '',
66 'fixed_period_rollover_day' => '',
67 'relationship_type_id' => '',
68 'relationship_direction' => '',
70 'visibility' => 'Public',
72 'receipt_text_signup' => '',
73 'receipt_text_renewal' => '',
76 'contribution_type_id' => '1',
81 return $expectedResult;
85 * This example has been generated from the API test suite.
86 * The test that created it is called "testCreate"
87 * and can be found at:
88 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTypeTest.php
90 * You can see the outcome of the API tests at
91 * https://test.civicrm.org/job/CiviCRM-master-git/
93 * To Learn about the API read
94 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
96 * Browse the api on your own site with the api explorer
97 * http://MYSITE.ORG/path/to/civicrm/api
99 * Read more about testing here
100 * http://wiki.civicrm.org/confluence/display/CRM/Testing
102 * API Standards documentation:
103 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards