Skip to content

Commit b6ce0a2

Browse files
committed
update compaign tests
1 parent 680692d commit b6ce0a2

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

tests/Resources/CompaignsTest.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,48 @@
1010
]);
1111
});
1212

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+
1349
it('can create and send a campaigns', function () {
1450
Http::fake([
1551
'https://sendy.test/api/campaigns/create.php' => Http::response(['status' => 'Campaign created and now sending'], 200),
1652
]);
1753

18-
$response = Sendy::campaigns()->create([
54+
$response = Sendy::campaigns()->createAndSend([
1955
'subject' => 'Test Subject',
2056
'from_name' => 'John Doe',
2157
'from_email' => '[email protected]',
@@ -31,7 +67,6 @@
3167
'query_string' => null,
3268
'track_opens' => 1,
3369
'track_clicks' => 1,
34-
'send_campaign' => 1,
3570
'schedule_date_time' => null,
3671
'schedule_timezone' => null,
3772
]);

0 commit comments

Comments
 (0)