Merge pull request #2714 from jitendrapurohit/CRMTestFix
[civicrm-core.git] / api / v3 / examples / PriceSet / Create.php
1 <?php
2 /**
3 * Test Generated example of using price_set create API
4 * *
5 */
6 function price_set_create_example(){
7 $params = array(
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
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 }
29
30 return $result;
31 }
32
33 /**
34 * Function returns array of result expected from previous function
35 */
36 function price_set_create_expectedresult(){
37
38 $expectedResult = array(
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 15,
43 'values' => array(
44 '15' => array(
45 'id' => '15',
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
61 return $expectedResult;
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 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PriceSetTest.php
70 *
71 * You can see the outcome of the API tests at
72 * https://test.civicrm.org/job/CiviCRM-master-git/
73 *
74 * To Learn about the API read
75 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
76 *
77 * Browse the api on your own site with the api explorer
78 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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 */