Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
50fb255d | 3 | * @file |
4 | * Test Generated API Example. | |
5 | * See bottom of this file for more detail. | |
6a488035 | 6 | */ |
6a488035 | 7 | |
50fb255d | 8 | /** |
9 | * Test Generated example of using line_item get API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function line_item_get_example() { | |
16 | $params = array( | |
17 | 'entity_table' => 'civicrm_contribution', | |
18 | ); | |
6a488035 | 19 | |
50fb255d | 20 | try{ |
21 | $result = civicrm_api3('line_item', 'get', $params); | |
22 | } | |
23 | catch (CiviCRM_API3_Exception $e) { | |
24 | // Handle error here. | |
25 | $errorMessage = $e->getMessage(); | |
26 | $errorCode = $e->getErrorCode(); | |
27 | $errorData = $e->getExtraParams(); | |
28 | return array( | |
29 | 'error' => $errorMessage, | |
30 | 'error_code' => $errorCode, | |
31 | 'error_data' => $errorData, | |
32 | ); | |
33 | } | |
34 | ||
35 | return $result; | |
6a488035 TO |
36 | } |
37 | ||
fb32de45 | 38 | /** |
50fb255d | 39 | * Function returns array of result expected from previous function. |
40 | * | |
41 | * @return array | |
42 | * API result array | |
6a488035 | 43 | */ |
50fb255d | 44 | function line_item_get_expectedresult() { |
6a488035 | 45 | |
53ca8fd7 | 46 | $expectedResult = array( |
50fb255d | 47 | 'is_error' => 0, |
48 | 'version' => 3, | |
49 | 'count' => 1, | |
50 | 'id' => 3, | |
51 | 'values' => array( | |
52 | '3' => array( | |
53 | 'id' => '3', | |
54 | 'entity_table' => 'civicrm_contribution', | |
55 | 'entity_id' => '2', | |
56 | 'contribution_id' => '2', | |
57 | 'price_field_id' => '1', | |
58 | 'label' => 'Contribution Amount', | |
59 | 'qty' => '1', | |
60 | 'unit_price' => '100.00', | |
61 | 'line_total' => '100.00', | |
62 | 'price_field_value_id' => '1', | |
63 | 'financial_type_id' => '1', | |
64 | 'deductible_amount' => '0.00', | |
65 | ), | |
6a488035 | 66 | ), |
50fb255d | 67 | ); |
6a488035 | 68 | |
fb32de45 | 69 | return $expectedResult; |
6a488035 TO |
70 | } |
71 | ||
50fb255d | 72 | /** |
73 | * This example has been generated from the API test suite. | |
74 | * The test that created it is called | |
75 | * testGetBasicLineItem | |
76 | * and can be found in | |
69d79249 | 77 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LineItemTest.php |
6a488035 TO |
78 | * |
79 | * You can see the outcome of the API tests at | |
69d79249 | 80 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
81 | * |
82 | * To Learn about the API read | |
69d79249 | 83 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 84 | * |
69d79249 E |
85 | * Browse the api on your own site with the api explorer |
86 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
87 | * |
88 | * Read more about testing here | |
89 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
90 | * | |
91 | * API Standards documentation: | |
92 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 93 | */ |