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