Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
50fb255d | 3 | * @file |
4 | * Test Generated API Example. | |
5 | * See bottom of this file for more detail. | |
6a488035 | 6 | */ |
6a488035 | 7 | |
50fb255d | 8 | /** |
9 | * Test Generated example of using price_field_value create API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function price_field_value_create_example() { | |
16 | $params = array( | |
17 | 'price_field_id' => 13, | |
18 | 'membership_type_id' => 5, | |
19 | 'name' => 'memType1', | |
20 | 'label' => 'memType1', | |
21 | 'amount' => 90, | |
22 | 'membership_num_terms' => 2, | |
23 | 'is_active' => 1, | |
24 | 'financial_type_id' => 2, | |
25 | ); | |
6a488035 | 26 | |
50fb255d | 27 | try{ |
28 | $result = civicrm_api3('price_field_value', 'create', $params); | |
29 | } | |
30 | catch (CiviCRM_API3_Exception $e) { | |
31 | // Handle error here. | |
32 | $errorMessage = $e->getMessage(); | |
33 | $errorCode = $e->getErrorCode(); | |
34 | $errorData = $e->getExtraParams(); | |
35 | return array( | |
36 | 'error' => $errorMessage, | |
37 | 'error_code' => $errorCode, | |
38 | 'error_data' => $errorData, | |
39 | ); | |
40 | } | |
41 | ||
42 | return $result; | |
6a488035 TO |
43 | } |
44 | ||
fb32de45 | 45 | /** |
50fb255d | 46 | * Function returns array of result expected from previous function. |
47 | * | |
48 | * @return array | |
49 | * API result array | |
6a488035 | 50 | */ |
50fb255d | 51 | function price_field_value_create_expectedresult() { |
6a488035 | 52 | |
53ca8fd7 | 53 | $expectedResult = array( |
50fb255d | 54 | 'is_error' => 0, |
55 | 'version' => 3, | |
56 | 'count' => 1, | |
57 | 'id' => 10, | |
58 | 'values' => array( | |
53ca8fd7 | 59 | '10' => array( |
50fb255d | 60 | 'id' => '10', |
61 | 'price_field_id' => '13', | |
62 | 'name' => 'memType1', | |
63 | 'label' => 'memType1', | |
64 | 'description' => '', | |
65 | 'amount' => '90', | |
66 | 'count' => '', | |
67 | 'max_value' => '', | |
68 | 'weight' => '1', | |
69 | 'membership_type_id' => '5', | |
70 | 'membership_num_terms' => '2', | |
71 | 'is_default' => '', | |
72 | 'is_active' => '1', | |
73 | 'financial_type_id' => '2', | |
74 | 'deductible_amount' => '', | |
75 | 'contribution_type_id' => '2', | |
76 | ), | |
6a488035 | 77 | ), |
50fb255d | 78 | ); |
6a488035 | 79 | |
fb32de45 | 80 | return $expectedResult; |
6a488035 TO |
81 | } |
82 | ||
50fb255d | 83 | /** |
84 | * This example has been generated from the API test suite. | |
85 | * The test that created it is called | |
86 | * testCreatePriceFieldValuewithMultipleTerms | |
87 | * and can be found in | |
69d79249 | 88 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PriceFieldValueTest.php |
6a488035 TO |
89 | * |
90 | * You can see the outcome of the API tests at | |
69d79249 | 91 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
92 | * |
93 | * To Learn about the API read | |
69d79249 | 94 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 95 | * |
69d79249 E |
96 | * Browse the api on your own site with the api explorer |
97 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
98 | * |
99 | * Read more about testing here | |
100 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
101 | * | |
102 | * API Standards documentation: | |
103 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 104 | */ |