Commit | Line | Data |
---|---|---|
71f1227b TO |
1 | <?php |
2 | ||
3 | namespace Civi\Test; | |
4 | ||
5 | /** | |
6 | * Class MailingTestTrait | |
7 | * @package Civi\Test | |
8 | * | |
9 | * This trait defines a number of helper functions for managing | |
10 | * test mailings. | |
11 | */ | |
12 | trait MailingTestTrait { | |
13 | ||
14 | /** | |
15 | * Helper function to create new mailing. | |
16 | * | |
17 | * @param array $params | |
18 | * | |
19 | * @return int | |
20 | */ | |
affcc9d2 | 21 | public function createMailing($params = []) { |
71f1227b TO |
22 | $params = array_merge(array( |
23 | 'subject' => 'maild' . rand(), | |
24 | 'body_text' => 'bdkfhdskfhduew{domain.address}{action.optOutUrl}', | |
25 | 'name' => 'mailing name' . rand(), | |
26 | 'created_id' => 1, | |
27 | ), $params); | |
28 | ||
29 | $result = $this->callAPISuccess('Mailing', 'create', $params); | |
30 | return $result['id']; | |
31 | } | |
32 | ||
33 | /** | |
34 | * Helper function to delete mailing. | |
35 | * @param $id | |
36 | */ | |
37 | public function deleteMailing($id) { | |
38 | $params = array( | |
39 | 'id' => $id, | |
40 | ); | |
41 | ||
42 | $this->callAPISuccess('Mailing', 'delete', $params); | |
43 | } | |
44 | ||
45 | } |