Merge remote-tracking branch 'upstream/4.5' into 4.5-4.6-2015-04-13-16-08-08
[civicrm-core.git] / tests / templates / documentFunction.tpl
1 {literal}<?php{/literal}
2 /**
3 * Test Generated example demonstrating the {$entity}.{$action} API.
4 *
5 {if !empty($result.deprecated) && is_string($result.deprecated)}
6 * @deprecated
7 * {$result.deprecated}
8 {if !$description}
9 *
10 {/if}
11 {/if}
12 {if $description}
13 {foreach from=$description item='line'}
14 * {$line}
15 {/foreach}
16 *
17 {/if}
18 * @return array
19 * API result array
20 */
21 function {$function}_example() {literal}{{/literal}
22 $params = {$params|@print_array};
23 {literal}
24 try{{/literal}
25 $result = civicrm_api3('{$entity}', '{$action}', $params);
26 {literal} }
27 catch (CiviCRM_API3_Exception $e) {
28 // Handle error here.
29 $errorMessage = $e->getMessage();
30 $errorCode = $e->getErrorCode();
31 $errorData = $e->getExtraParams();
32 return array(
33 'error' => $errorMessage,
34 'error_code' => $errorCode,
35 'error_data' => $errorData,
36 );
37 }{/literal}
38
39 return $result;
40 {literal}}{/literal}
41
42 /**
43 * Function returns array of result expected from previous function.
44 *
45 * @return array
46 * API result array
47 */
48 function {$function}_expectedresult() {literal}{{/literal}
49
50 $expectedResult = {$result|@print_array};
51
52 return $expectedResult;
53 {literal}}{/literal}
54
55 /*
56 * This example has been generated from the API test suite.
57 * The test that created it is called "{$testFunction}"
58 * and can be found at:
59 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/{$testFile}
60 *
61 * You can see the outcome of the API tests at
62 * https://test.civicrm.org/job/CiviCRM-master-git/
63 *
64 * To Learn about the API read
65 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
66 *
67 * Browse the api on your own site with the api explorer
68 * http://MYSITE.ORG/path/to/civicrm/api
69 *
70 * Read more about testing here
71 * http://wiki.civicrm.org/confluence/display/CRM/Testing
72 *
73 * API Standards documentation:
74 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
75 */