Commit | Line | Data |
---|---|---|
d8c20bdb D |
1 | <?php |
2 | ||
3 | /** | |
4 | * Test SMS Preview | |
5 | * | |
6 | * @group headless | |
7 | */ | |
8 | class CRM_SMS_PreviewTest extends CiviUnitTestCase { | |
9 | ||
10 | /** | |
11 | * Set Up Function | |
12 | */ | |
13 | public function setUp() { | |
14 | parent::setUp(); | |
15 | $option = $this->callAPISuccess('option_value', 'create', ['option_group_id' => 'sms_provider_name', 'name' => 'test_provider_name', 'label' => 'Test Provider Label', 'value' => 1]); | |
16 | $this->option_value = $option['id']; | |
17 | } | |
18 | ||
19 | /** | |
20 | * Clean up after each test. | |
21 | */ | |
dd09ee0c | 22 | public function tearDown(): void { |
d8c20bdb D |
23 | parent::tearDown(); |
24 | $this->callAPISuccess('option_value', 'delete', ['id' => $this->option_value]); | |
25 | } | |
26 | ||
27 | /** | |
28 | * Test SMS preview. | |
29 | */ | |
30 | public function testSMSPreview() { | |
31 | $result = $this->callAPISuccess('SmsProvider', 'create', [ | |
32 | 'title' => 'test SMS provider', | |
33 | 'username' => 'test', | |
34 | 'password' => 'password', | |
35 | // 'name' is the option_value 'value' (not id, not name) we created in setUp() | |
36 | 'name' => 1, | |
37 | 'is_active' => 1, | |
38 | 'is_default' => 1, | |
39 | 'api_type' => 1, | |
40 | ]); | |
41 | $provider_id = $result['id']; | |
42 | $result = $this->callAPISuccess('Mailing', 'create', [ | |
43 | 'name' => "Test1", | |
44 | 'from_name' => "+12223334444", | |
45 | 'from_email' => "test@test.com", | |
46 | 'replyto_email' => "test@test.com", | |
47 | 'body_text' => "Testing body", | |
48 | 'sms_provider_id' => $provider_id, | |
49 | 'header_id' => NULL, | |
50 | 'footer_id' => NULL, | |
51 | 'unsubscribe_id' => NULL, | |
52 | ]); | |
53 | $mailing_id = $result['id']; | |
54 | $result = $this->callAPISuccess('Mailing', 'preview', [ | |
55 | 'id' => $mailing_id, | |
56 | ]); | |
57 | } | |
58 | ||
59 | } |