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 create API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function price_field_create_example() { | |
16 | $params = array( | |
17 | 'price_set_id' => 3, | |
18 | 'name' => 'grassvariety', | |
19 | 'label' => 'Grass Variety', | |
20 | 'html_type' => 'Text', | |
21 | 'is_enter_qty' => 1, | |
22 | 'is_active' => 1, | |
23 | ); | |
6a488035 | 24 | |
50fb255d | 25 | try{ |
26 | $result = civicrm_api3('price_field', 'create', $params); | |
27 | } | |
28 | catch (CiviCRM_API3_Exception $e) { | |
29 | // Handle error here. | |
30 | $errorMessage = $e->getMessage(); | |
31 | $errorCode = $e->getErrorCode(); | |
32 | $errorData = $e->getExtraParams(); | |
33 | return array( | |
34 | 'error' => $errorMessage, | |
35 | 'error_code' => $errorCode, | |
36 | 'error_data' => $errorData, | |
37 | ); | |
38 | } | |
39 | ||
40 | return $result; | |
6a488035 TO |
41 | } |
42 | ||
fb32de45 | 43 | /** |
50fb255d | 44 | * Function returns array of result expected from previous function. |
45 | * | |
46 | * @return array | |
47 | * API result array | |
6a488035 | 48 | */ |
50fb255d | 49 | function price_field_create_expectedresult() { |
6a488035 | 50 | |
53ca8fd7 | 51 | $expectedResult = array( |
50fb255d | 52 | 'is_error' => 0, |
53 | 'version' => 3, | |
54 | 'count' => 1, | |
55 | 'id' => 2, | |
56 | 'values' => array( | |
53ca8fd7 | 57 | '2' => array( |
50fb255d | 58 | 'id' => '2', |
59 | 'price_set_id' => '3', | |
60 | 'name' => 'grassvariety', | |
61 | 'label' => 'Grass Variety', | |
62 | 'html_type' => 'Text', | |
63 | 'is_enter_qty' => '1', | |
64 | 'help_pre' => '', | |
65 | 'help_post' => '', | |
66 | 'weight' => '', | |
67 | 'is_display_amounts' => '', | |
68 | 'options_per_line' => '', | |
69 | 'is_active' => '1', | |
70 | 'is_required' => '', | |
71 | 'active_on' => '', | |
72 | 'expire_on' => '', | |
73 | 'javascript' => '', | |
74 | 'visibility_id' => '', | |
75 | ), | |
6a488035 | 76 | ), |
50fb255d | 77 | ); |
6a488035 | 78 | |
fb32de45 | 79 | return $expectedResult; |
6a488035 TO |
80 | } |
81 | ||
50fb255d | 82 | /** |
83 | * This example has been generated from the API test suite. | |
84 | * The test that created it is called | |
85 | * testCreatePriceField | |
86 | * and can be found in | |
69d79249 | 87 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PriceFieldTest.php |
6a488035 TO |
88 | * |
89 | * You can see the outcome of the API tests at | |
69d79249 | 90 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
91 | * |
92 | * To Learn about the API read | |
69d79249 | 93 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 94 | * |
69d79249 E |
95 | * Browse the api on your own site with the api explorer |
96 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
97 | * |
98 | * Read more about testing here | |
99 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
100 | * | |
101 | * API Standards documentation: | |
102 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 103 | */ |