Commit | Line | Data |
---|---|---|
5be22f39 | 1 | <?php |
2 | /** | |
3 | * Test Generated example demonstrating the Mailing.clone API. | |
4 | * | |
5 | * @return array | |
6 | * API result array | |
7 | */ | |
8 | function mailing_clone_example() { | |
cf8f0fff | 9 | $params = [ |
8390b11b | 10 | 'id' => 27, |
cf8f0fff | 11 | ]; |
5be22f39 | 12 | |
13 | try{ | |
14 | $result = civicrm_api3('Mailing', 'clone', $params); | |
15 | } | |
16 | catch (CiviCRM_API3_Exception $e) { | |
17 | // Handle error here. | |
18 | $errorMessage = $e->getMessage(); | |
19 | $errorCode = $e->getErrorCode(); | |
20 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 21 | return [ |
5be22f39 | 22 | 'is_error' => 1, |
23 | 'error_message' => $errorMessage, | |
24 | 'error_code' => $errorCode, | |
25 | 'error_data' => $errorData, | |
cf8f0fff | 26 | ]; |
5be22f39 | 27 | } |
28 | ||
29 | return $result; | |
30 | } | |
31 | ||
32 | /** | |
33 | * Function returns array of result expected from previous function. | |
34 | * | |
35 | * @return array | |
36 | * API result array | |
37 | */ | |
38 | function mailing_clone_expectedresult() { | |
39 | ||
cf8f0fff | 40 | $expectedResult = [ |
5be22f39 | 41 | 'is_error' => 0, |
42 | 'version' => 3, | |
43 | 'count' => 1, | |
8390b11b | 44 | 'id' => 28, |
cf8f0fff | 45 | 'values' => [ |
8390b11b SL |
46 | '28' => [ |
47 | 'id' => '28', | |
5be22f39 | 48 | 'domain_id' => '1', |
49 | 'header_id' => '1', | |
50 | 'footer_id' => '2', | |
51 | 'reply_id' => '8', | |
52 | 'unsubscribe_id' => '5', | |
53 | 'resubscribe_id' => '6', | |
54 | 'optout_id' => '7', | |
55 | 'name' => 'mailing name', | |
56 | 'mailing_type' => 'standalone', | |
57 | 'from_name' => 'FIXME', | |
58 | 'from_email' => 'info@EXAMPLE.ORG', | |
59 | 'replyto_email' => 'info@EXAMPLE.ORG', | |
60 | 'template_type' => 'traditional', | |
61 | 'template_options' => '', | |
62 | 'subject' => 'Hello {contact.display_name}', | |
63 | 'body_text' => 'This is {contact.display_name}. | |
64 | https://civicrm.org | |
65 | {domain.address}{action.optOutUrl}', | |
8390b11b | 66 | 'body_html' => '<link href=\'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Zilla+Slab:500,700\' rel=\'stylesheet\' type=\'text/css\'><p><a href=\"http://{action.forward}\">Forward this email</a><a href=\"{action.forward}\">Forward this email with no protocol</a></p<p>This is {contact.display_name}.</p><p><a href=\'https://civicrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>', |
5be22f39 | 67 | 'url_tracking' => '1', |
68 | 'forward_replies' => 0, | |
69 | 'auto_responder' => 0, | |
70 | 'open_tracking' => '1', | |
71 | 'is_completed' => '', | |
72 | 'msg_template_id' => '', | |
73 | 'override_verp' => '1', | |
8390b11b | 74 | 'created_id' => '154', |
5be22f39 | 75 | 'created_date' => '2013-07-28 08:49:19', |
8390b11b | 76 | 'modified_date' => '2012-11-14 16:02:35', |
5be22f39 | 77 | 'scheduled_id' => '', |
78 | 'scheduled_date' => '', | |
79 | 'approver_id' => '', | |
80 | 'approval_date' => '', | |
81 | 'approval_status_id' => '', | |
82 | 'approval_note' => '', | |
8390b11b | 83 | 'is_archived' => 0, |
5be22f39 | 84 | 'visibility' => 'Public Pages', |
85 | 'campaign_id' => '', | |
86 | 'dedupe_email' => '1', | |
87 | 'sms_provider_id' => '', | |
88 | 'hash' => '', | |
89 | 'location_type_id' => '', | |
90 | 'email_selection_method' => 'automatic', | |
91 | 'language' => '', | |
cf8f0fff CW |
92 | ], |
93 | ], | |
94 | ]; | |
5be22f39 | 95 | |
96 | return $expectedResult; | |
97 | } | |
98 | ||
99 | /* | |
100 | * This example has been generated from the API test suite. | |
101 | * The test that created it is called "testClone" | |
102 | * and can be found at: | |
103 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php | |
104 | * | |
105 | * You can see the outcome of the API tests at | |
8390b11b | 106 | * https://test.civicrm.org/job/CiviCRM-Core-Matrix/ |
5be22f39 | 107 | * |
108 | * To Learn about the API read | |
8390b11b | 109 | * https://docs.civicrm.org/dev/en/latest/api/ |
5be22f39 | 110 | * |
8390b11b SL |
111 | * Browse the API on your own site with the API Explorer. It is in the main |
112 | * CiviCRM menu, under: Support > Development > API Explorer. | |
5be22f39 | 113 | * |
114 | * Read more about testing here | |
8390b11b | 115 | * https://docs.civicrm.org/dev/en/latest/testing/ |
5be22f39 | 116 | * |
117 | * API Standards documentation: | |
8390b11b | 118 | * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/ |
5be22f39 | 119 | */ |