Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using price_field create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function price_field_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'price_set_id' => 3, |
9 | 'name' => 'grassvariety', | |
10 | 'label' => 'Grass Variety', | |
11 | 'html_type' => 'Text', | |
12 | 'is_enter_qty' => 1, | |
13 | 'is_active' => 1, | |
14 | ); | |
15 | ||
fb32de45 | 16 | try{ |
17 | $result = civicrm_api3('price_field', 'create', $params); | |
18 | } | |
19 | catch (CiviCRM_API3_Exception $e) { | |
20 | // handle error here | |
21 | $errorMessage = $e->getMessage(); | |
22 | $errorCode = $e->getErrorCode(); | |
23 | $errorData = $e->getExtraParams(); | |
24 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
25 | } | |
6a488035 | 26 | |
fb32de45 | 27 | return $result; |
6a488035 TO |
28 | } |
29 | ||
fb32de45 | 30 | /** |
6a488035 TO |
31 | * Function returns array of result expected from previous function |
32 | */ | |
33 | function price_field_create_expectedresult(){ | |
34 | ||
53ca8fd7 | 35 | $expectedResult = array( |
6a488035 TO |
36 | 'is_error' => 0, |
37 | 'version' => 3, | |
38 | 'count' => 1, | |
39 | 'id' => 2, | |
53ca8fd7 | 40 | 'values' => array( |
41 | '2' => array( | |
6a488035 TO |
42 | 'id' => '2', |
43 | 'price_set_id' => '3', | |
44 | 'name' => 'grassvariety', | |
45 | 'label' => 'Grass Variety', | |
46 | 'html_type' => 'Text', | |
47 | 'is_enter_qty' => '1', | |
48 | 'help_pre' => '', | |
49 | 'help_post' => '', | |
50 | 'weight' => '', | |
51 | 'is_display_amounts' => '', | |
52 | 'options_per_line' => '', | |
53 | 'is_active' => '1', | |
54 | 'is_required' => '', | |
55 | 'active_on' => '', | |
56 | 'expire_on' => '', | |
57 | 'javascript' => '', | |
58 | 'visibility_id' => '', | |
59 | ), | |
60 | ), | |
61 | ); | |
62 | ||
fb32de45 | 63 | return $expectedResult; |
6a488035 TO |
64 | } |
65 | ||
66 | ||
67 | /* | |
68 | * This example has been generated from the API test suite. The test that created it is called | |
69 | * | |
70 | * testCreatePriceField and can be found in | |
71 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/PriceFieldTest.php | |
72 | * | |
73 | * You can see the outcome of the API tests at | |
74 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
75 | * | |
76 | * To Learn about the API read | |
77 | * http://book.civicrm.org/developer/current/techniques/api/ | |
78 | * | |
79 | * and review the wiki at | |
80 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
81 | * | |
82 | * Read more about testing here | |
83 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
84 | * | |
85 | * API Standards documentation: | |
86 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
87 | */ |