Commit | Line | Data |
---|---|---|
397e0e51 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the MessageTemplate.create API. |
50fb255d | 4 | * |
50fb255d | 5 | * @return array |
6 | * API result array | |
7 | */ | |
8 | function message_template_create_example() { | |
9 | $params = array( | |
10 | 'msg_title' => 'msg_title_165', | |
11 | 'msg_subject' => 'msg_subject_165', | |
12 | 'msg_text' => 'msg_text_165', | |
13 | 'msg_html' => 'msg_html_165', | |
14 | 'workflow_id' => 165, | |
15 | 'is_default' => '1', | |
16 | 'is_reserved' => 1, | |
17 | ); | |
397e0e51 | 18 | |
50fb255d | 19 | try{ |
a828d7b8 | 20 | $result = civicrm_api3('MessageTemplate', 'create', $params); |
50fb255d | 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( | |
28 | 'error' => $errorMessage, | |
29 | 'error_code' => $errorCode, | |
30 | 'error_data' => $errorData, | |
31 | ); | |
32 | } | |
33 | ||
34 | return $result; | |
397e0e51 EC |
35 | } |
36 | ||
37 | /** | |
50fb255d | 38 | * Function returns array of result expected from previous function. |
39 | * | |
40 | * @return array | |
41 | * API result array | |
397e0e51 | 42 | */ |
50fb255d | 43 | function message_template_create_expectedresult() { |
397e0e51 EC |
44 | |
45 | $expectedResult = array( | |
50fb255d | 46 | 'is_error' => 0, |
47 | 'version' => 3, | |
48 | 'count' => 1, | |
5c49fee0 | 49 | 'id' => 67, |
50fb255d | 50 | 'values' => array( |
5c49fee0 CW |
51 | '67' => array( |
52 | 'id' => '67', | |
50fb255d | 53 | 'msg_title' => 'msg_title_165', |
54 | 'msg_subject' => 'msg_subject_165', | |
55 | 'msg_text' => 'msg_text_165', | |
56 | 'msg_html' => 'msg_html_165', | |
57 | 'is_active' => '1', | |
58 | 'workflow_id' => '165', | |
59 | 'is_default' => '1', | |
60 | 'is_reserved' => '1', | |
61 | 'is_sms' => '', | |
62 | 'pdf_format_id' => '', | |
63 | ), | |
397e0e51 | 64 | ), |
50fb255d | 65 | ); |
397e0e51 EC |
66 | |
67 | return $expectedResult; | |
68 | } | |
69 | ||
a828d7b8 | 70 | /* |
50fb255d | 71 | * This example has been generated from the API test suite. |
a828d7b8 CW |
72 | * The test that created it is called "testCreate" |
73 | * and can be found at: | |
69d79249 | 74 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MessageTemplateTest.php |
397e0e51 EC |
75 | * |
76 | * You can see the outcome of the API tests at | |
69d79249 | 77 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
397e0e51 EC |
78 | * |
79 | * To Learn about the API read | |
69d79249 | 80 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
397e0e51 | 81 | * |
69d79249 | 82 | * Browse the api on your own site with the api explorer |
41d4d31f | 83 | * http://MYSITE.ORG/path/to/civicrm/api |
397e0e51 EC |
84 | * |
85 | * Read more about testing here | |
86 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
87 | * | |
88 | * API Standards documentation: | |
89 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 90 | */ |