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