Update test examples.
[civicrm-core.git] / api / v3 / examples / Mailing / Submit.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Mailing.submit API.
4 *
5 * @return array
6 * API result array
7 */
8 function mailing_submit_example() {
9 $params = array(
10 'scheduled_date' => '2014-12-13 10:00:00',
11 'approval_date' => '2014-12-13 00:00:00',
12 'id' => 16,
13 );
14
15 try{
16 $result = civicrm_api3('Mailing', 'submit', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
24 'is_error' => 1,
25 'error_message' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 );
29 }
30
31 return $result;
32 }
33
34 /**
35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
39 */
40 function mailing_submit_expectedresult() {
41
42 $expectedResult = array(
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 16,
47 'values' => array(
48 '16' => array(
49 'id' => '16',
50 'domain_id' => '1',
51 'header_id' => '',
52 'footer_id' => '24',
53 'reply_id' => '8',
54 'unsubscribe_id' => '5',
55 'resubscribe_id' => '6',
56 'optout_id' => '7',
57 'name' => 'mailing name',
58 'from_name' => 'FIXME',
59 'from_email' => 'info@EXAMPLE.ORG',
60 'replyto_email' => 'info@EXAMPLE.ORG',
61 'subject' => 'Hello {contact.display_name}',
62 'body_text' => 'This is {contact.display_name}.
63 {domain.address}{action.optOutUrl}',
64 'body_html' => '<p>Look ma, magic tokens in the markup!</p>',
65 'url_tracking' => '1',
66 'forward_replies' => 0,
67 'auto_responder' => 0,
68 'open_tracking' => '1',
69 'is_completed' => '',
70 'msg_template_id' => '',
71 'override_verp' => '1',
72 'created_id' => '35',
73 'created_date' => '2013-07-28 08:49:19',
74 'scheduled_id' => '36',
75 'scheduled_date' => '20130728085413',
76 'approver_id' => '36',
77 'approval_date' => '20130728085413',
78 'approval_status_id' => '1',
79 'approval_note' => '',
80 'is_archived' => 0,
81 'visibility' => 'Public Pages',
82 'campaign_id' => '',
83 'dedupe_email' => '1',
84 'sms_provider_id' => '',
85 'hash' => '67eac7789eaee00',
86 'location_type_id' => 0,
87 'email_selection_method' => 'automatic',
88 ),
89 ),
90 );
91
92 return $expectedResult;
93 }
94
95 /*
96 * This example has been generated from the API test suite.
97 * The test that created it is called "testMailerSubmit"
98 * and can be found at:
99 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php
100 *
101 * You can see the outcome of the API tests at
102 * https://test.civicrm.org/job/CiviCRM-master-git/
103 *
104 * To Learn about the API read
105 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
106 *
107 * Browse the api on your own site with the api explorer
108 * http://MYSITE.ORG/path/to/civicrm/api
109 *
110 * Read more about testing here
111 * http://wiki.civicrm.org/confluence/display/CRM/Testing
112 *
113 * API Standards documentation:
114 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
115 */