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