Merge pull request #7286 from eileenmcnaughton/CRM-16929-salvage
[civicrm-core.git] / tests / templates / documentFunction.tpl
CommitLineData
6a488035 1{literal}<?php{/literal}
0c13f046 2/**
a828d7b8 3 * Test Generated example demonstrating the {$entity}.{$action} API.
0c13f046 4 *
a6ec24c4
CW
5{if !empty($result.deprecated) && is_string($result.deprecated)}
6 * @deprecated
7 * {$result.deprecated}
8{if !$description}
9 *
10{/if}
11{/if}
0c13f046 12{if $description}
5c49fee0
CW
13{foreach from=$description item='line'}
14 * {$line}
15{/foreach}
947a37b4 16 *
7aaa05d2 17{/if}
0c13f046
EM
18 * @return array
19 * API result array
6a488035 20 */
0c13f046
EM
21function {$function}_example() {literal}{{/literal}
22 $params = {$params|@print_array};
947a37b4 23{literal}
0c13f046 24 try{{/literal}
a828d7b8 25 $result = civicrm_api3('{$entity}', '{$action}', $params);
0c13f046
EM
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}
947a37b4 38
0c13f046 39 return $result;
6a488035
TO
40{literal}}{/literal}
41
947a37b4 42/**
0c13f046
EM
43 * Function returns array of result expected from previous function.
44 *
45 * @return array
46 * API result array
6a488035 47 */
0c13f046 48function {$function}_expectedresult() {literal}{{/literal}
6a488035
TO
49
50 $expectedResult = {$result|@print_array};
51
947a37b4 52 return $expectedResult;
6a488035
TO
53{literal}}{/literal}
54
a828d7b8 55/*
0c13f046 56* This example has been generated from the API test suite.
a828d7b8
CW
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}
6a488035
TO
60*
61* You can see the outcome of the API tests at
3ec6e38d 62* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
63*
64* To Learn about the API read
3ec6e38d 65* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 66*
3ec6e38d 67* Browse the api on your own site with the api explorer
41d4d31f 68* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
fb32de45 75*/