Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using price_field_value create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function price_field_value_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'price_field_id' => 13, |
9 | 'membership_type_id' => 5, | |
10 | 'name' => 'memType1', | |
11 | 'label' => 'memType1', | |
12 | 'amount' => 90, | |
13 | 'membership_num_terms' => 2, | |
14 | 'is_active' => 1, | |
15 | 'financial_type_id' => 2, | |
16 | ); | |
17 | ||
fb32de45 | 18 | try{ |
19 | $result = civicrm_api3('price_field_value', '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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
27 | } | |
6a488035 | 28 | |
fb32de45 | 29 | return $result; |
6a488035 TO |
30 | } |
31 | ||
fb32de45 | 32 | /** |
6a488035 TO |
33 | * Function returns array of result expected from previous function |
34 | */ | |
35 | function price_field_value_create_expectedresult(){ | |
36 | ||
53ca8fd7 | 37 | $expectedResult = array( |
6a488035 TO |
38 | 'is_error' => 0, |
39 | 'version' => 3, | |
40 | 'count' => 1, | |
41 | 'id' => 10, | |
53ca8fd7 | 42 | 'values' => array( |
43 | '10' => array( | |
6a488035 TO |
44 | 'id' => '10', |
45 | 'price_field_id' => '13', | |
46 | 'name' => 'memType1', | |
47 | 'label' => 'memType1', | |
48 | 'description' => '', | |
49 | 'amount' => '90', | |
50 | 'count' => '', | |
51 | 'max_value' => '', | |
52 | 'weight' => '1', | |
53 | 'membership_type_id' => '5', | |
54 | 'membership_num_terms' => '2', | |
55 | 'is_default' => '', | |
56 | 'is_active' => '1', | |
57 | 'financial_type_id' => '2', | |
58 | 'deductible_amount' => '', | |
53ca8fd7 | 59 | 'contribution_type_id' => '2', |
6a488035 TO |
60 | ), |
61 | ), | |
62 | ); | |
63 | ||
fb32de45 | 64 | return $expectedResult; |
6a488035 TO |
65 | } |
66 | ||
67 | ||
68 | /* | |
69 | * This example has been generated from the API test suite. The test that created it is called | |
70 | * | |
71 | * testCreatePriceFieldValuewithMultipleTerms and can be found in | |
72 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/PriceFieldValueTest.php | |
73 | * | |
74 | * You can see the outcome of the API tests at | |
75 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
76 | * | |
77 | * To Learn about the API read | |
78 | * http://book.civicrm.org/developer/current/techniques/api/ | |
79 | * | |
80 | * and review the wiki at | |
81 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
82 | * | |
83 | * Read more about testing here | |
84 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
85 | * | |
86 | * API Standards documentation: | |
87 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
88 | */ |