Merge pull request #22634 from eileenmcnaughton/pre_message
[civicrm-core.git] / tests / templates / documentFunction.tpl
1 {literal}<?php{/literal}
2
3 /**
4 * @file
5 */
6
7 /**
8 * Test Generated example demonstrating the {$entity}.{$action} API.
9 *
10 {if !empty($result.deprecated) && is_string($result.deprecated)}
11 * @deprecated
12 * {$result.deprecated}
13 {if !$description}
14 *
15 {/if}
16 {/if}
17 {if $description}
18 {foreach from=$description item='line'}
19 * {$line}
20 {/foreach}
21 *
22 {/if}
23 * @return array
24 * API result array
25 */
26 function {$function}_example() {literal}{{/literal}
27 $params = {$params|@print_array};
28 {literal}
29 try {{/literal}
30 $result = civicrm_api3('{$entity}', '{$action}', $params);
31 {literal} }
32 catch (CiviCRM_API3_Exception $e) {
33 // Handle error here.
34 $errorMessage = $e->getMessage();
35 $errorCode = $e->getErrorCode();
36 $errorData = $e->getExtraParams();
37 return [
38 'is_error' => 1,
39 'error_message' => $errorMessage,
40 'error_code' => $errorCode,
41 'error_data' => $errorData,
42 ];
43 }{/literal}
44
45 return $result;
46 {literal}}{/literal}
47
48 /**
49 * Function returns array of result expected from previous function.
50 *
51 * @return array
52 * API result array
53 */
54 function {$function}_expectedresult() {literal}{{/literal}
55
56 $expectedResult = {$result|@print_array};
57
58 return $expectedResult;
59 {literal}}{/literal}
60
61 /*
62 * This example has been generated from the API test suite.
63 * The test that created it is called "{$testFunction}"
64 * and can be found at:
65 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/{$testFile}
66 *
67 * You can see the outcome of the API tests at
68 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
69 *
70 * To Learn about the API read
71 * https://docs.civicrm.org/dev/en/latest/api/
72 *
73 * Browse the API on your own site with the API Explorer. It is in the main
74 * CiviCRM menu, under: Support > Development > API Explorer.
75 *
76 * Read more about testing here
77 * https://docs.civicrm.org/dev/en/latest/testing/
78 *
79 * API Standards documentation:
80 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
81 */