|
10 | 10 | ]);
|
11 | 11 | });
|
12 | 12 |
|
| 13 | +it('can create a campaigns', function () { |
| 14 | + Http::fake([ |
| 15 | + 'https://sendy.test/api/campaigns/create.php' => Http::response(['status' => 'Campaign created'], 200), |
| 16 | + ]); |
| 17 | + |
| 18 | + $response = Sendy::campaigns()->create([ |
| 19 | + 'subject' => 'Test Subject', |
| 20 | + 'from_name' => 'John Doe', |
| 21 | + 'from_email' => '[email protected]', |
| 22 | + 'reply_to' => '[email protected]', |
| 23 | + 'title' => 'Test Title', |
| 24 | + 'plain_text' => 'This is a plain text version of the email.', |
| 25 | + 'html_text' => '<h1>This is a HTML version of the email.</h1>', |
| 26 | + 'list_ids' => 'abc123', |
| 27 | + 'segment_ids' => 'xyz456', |
| 28 | + 'exclude_list_ids' => null, |
| 29 | + 'exclude_segment_ids' => null, |
| 30 | + 'brand_id' => 'brand123', |
| 31 | + 'query_string' => null, |
| 32 | + 'track_opens' => 1, |
| 33 | + 'track_clicks' => 1, |
| 34 | + 'send_campaign' => 0, |
| 35 | + 'schedule_date_time' => null, |
| 36 | + 'schedule_timezone' => null, |
| 37 | + ]); |
| 38 | + |
| 39 | + expect($response->json())->toBe(['status' => 'Campaign created']); |
| 40 | + |
| 41 | + Http::assertSent(function ($request) { |
| 42 | + return $request->url() === 'https://sendy.test/api/campaigns/create.php' && |
| 43 | + $request[ 'from_email'] === '[email protected]' && |
| 44 | + $request['from_name'] === 'John Doe' && |
| 45 | + $request['api_key'] === 'test_api_key'; |
| 46 | + }); |
| 47 | +}); |
| 48 | + |
13 | 49 | it('can create and send a campaigns', function () {
|
14 | 50 | Http::fake([
|
15 | 51 | 'https://sendy.test/api/campaigns/create.php' => Http::response(['status' => 'Campaign created and now sending'], 200),
|
16 | 52 | ]);
|
17 | 53 |
|
18 |
| - $response = Sendy::campaigns()->create([ |
| 54 | + $response = Sendy::campaigns()->createAndSend([ |
19 | 55 | 'subject' => 'Test Subject',
|
20 | 56 | 'from_name' => 'John Doe',
|
21 | 57 | 'from_email' => '[email protected]',
|
|
31 | 67 | 'query_string' => null,
|
32 | 68 | 'track_opens' => 1,
|
33 | 69 | 'track_clicks' => 1,
|
34 |
| - 'send_campaign' => 1, |
35 | 70 | 'schedule_date_time' => null,
|
36 | 71 | 'schedule_timezone' => null,
|
37 | 72 | ]);
|
|
0 commit comments