Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using membership_type create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function membership_type_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'name' => '40+ Membership', |
9 | 'description' => 'people above 40 are given health instructions', | |
10 | 'member_of_contact_id' => 1, | |
11 | 'financial_type_id' => 1, | |
12 | 'domain_id' => '1', | |
13 | 'minimum_fee' => '200', | |
14 | 'duration_unit' => 'month', | |
15 | 'duration_interval' => '10', | |
16 | 'period_type' => 'rolling', | |
17 | 'visibility' => 'public', | |
6a488035 TO |
18 | ); |
19 | ||
fb32de45 | 20 | try{ |
21 | $result = civicrm_api3('membership_type', 'create', $params); | |
22 | } | |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // handle error here | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
28 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
29 | } | |
6a488035 | 30 | |
fb32de45 | 31 | return $result; |
6a488035 TO |
32 | } |
33 | ||
fb32de45 | 34 | /** |
6a488035 TO |
35 | * Function returns array of result expected from previous function |
36 | */ | |
37 | function membership_type_create_expectedresult(){ | |
38 | ||
53ca8fd7 | 39 | $expectedResult = array( |
6a488035 TO |
40 | 'is_error' => 0, |
41 | 'version' => 3, | |
42 | 'count' => 1, | |
43 | 'id' => 2, | |
53ca8fd7 | 44 | 'values' => array( |
45 | '2' => array( | |
6a488035 TO |
46 | 'id' => '2', |
47 | 'domain_id' => '1', | |
48 | 'name' => '40+ Membership', | |
49 | 'description' => 'people above 40 are given health instructions', | |
50 | 'member_of_contact_id' => '1', | |
51 | 'financial_type_id' => '1', | |
52 | 'minimum_fee' => '200', | |
53 | 'duration_unit' => 'month', | |
54 | 'duration_interval' => '10', | |
55 | 'period_type' => 'rolling', | |
56 | 'fixed_period_start_day' => '', | |
57 | 'fixed_period_rollover_day' => '', | |
58 | 'relationship_type_id' => '', | |
59 | 'relationship_direction' => '', | |
60 | 'max_related' => '', | |
53ca8fd7 | 61 | 'visibility' => '1', |
6a488035 TO |
62 | 'weight' => '', |
63 | 'receipt_text_signup' => '', | |
64 | 'receipt_text_renewal' => '', | |
65 | 'auto_renew' => '', | |
66 | 'is_active' => '', | |
53ca8fd7 | 67 | 'contribution_type_id' => '1', |
6a488035 TO |
68 | ), |
69 | ), | |
70 | ); | |
71 | ||
fb32de45 | 72 | return $expectedResult; |
6a488035 TO |
73 | } |
74 | ||
75 | ||
76 | /* | |
77 | * This example has been generated from the API test suite. The test that created it is called | |
78 | * | |
79 | * testCreate and can be found in | |
69d79249 | 80 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTypeTest.php |
6a488035 TO |
81 | * |
82 | * You can see the outcome of the API tests at | |
69d79249 | 83 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
84 | * |
85 | * To Learn about the API read | |
69d79249 | 86 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 87 | * |
69d79249 E |
88 | * Browse the api on your own site with the api explorer |
89 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
90 | * |
91 | * Read more about testing here | |
92 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
93 | * | |
94 | * API Standards documentation: | |
95 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 96 | */ |