@@ -25,11 +25,11 @@ function test_mailSend_calls_sparkpost_send() {
25
25
$ stub = Mockery::mock ($ this ->mailer );
26
26
$ stub ->shouldReceive ('sparkpost_send ' )->andReturn ('woowoo ' );
27
27
28
- $ this ->assertTrue (NSA ::invokeMethod ($ stub , 'mailSend ' , null , null ) == 'woowoo ' );
28
+ $ this ->assertEquals (NSA ::invokeMethod ($ stub , 'mailSend ' , null , null ), 'woowoo ' );
29
29
}
30
30
31
31
function test_mailer_is_a_mailer_instance () {
32
- $ this ->assertTrue ( $ this ->mailer instanceof \PHPMailer );
32
+ $ this ->assertTrue ( $ this ->mailer instanceof \PHPMailer \ PHPMailer \PHPMailer );
33
33
}
34
34
35
35
function test_get_sender_with_name () {
@@ -39,7 +39,7 @@ function test_get_sender_with_name() {
39
39
'email ' => 'me@hello.com '
40
40
);
41
41
42
- $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_sender ' ) == $ sender );
42
+ $ this ->assertEquals (NSA ::invokeMethod ($ this ->mailer , 'get_sender ' ), $ sender );
43
43
}
44
44
45
45
function test_get_sender_without_name () {
@@ -48,7 +48,7 @@ function test_get_sender_without_name() {
48
48
'email ' => 'me@hello.com '
49
49
);
50
50
51
- $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_sender ' ) == $ sender );
51
+ $ this ->assertEquals (NSA ::invokeMethod ($ this ->mailer , 'get_sender ' ), $ sender );
52
52
}
53
53
54
54
function test_get_request_headers () {
@@ -57,15 +57,15 @@ function test_get_request_headers() {
57
57
'Content-Type ' => 'application/json ' ,
58
58
'Authorization ' => ''
59
59
);
60
- $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' ) == $ expected );
60
+ $ this ->assertEquals (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' ), $ expected );
61
61
62
62
NSA ::setProperty ($ this ->mailer , 'settings ' , array ('password ' => 'abcd1234 ' ));
63
63
$ expected = array (
64
64
'User-Agent ' => 'wordpress-sparkpost/ ' . WPSP_PLUGIN_VERSION ,
65
65
'Content-Type ' => 'application/json ' ,
66
66
'Authorization ' => 'abcd1234 '
67
67
);
68
- $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' ) == $ expected );
68
+ $ this ->assertEquals (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' ), $ expected );
69
69
}
70
70
71
71
function test_get_request_headers_obfuscate_key () {
@@ -75,48 +75,59 @@ function test_get_request_headers_obfuscate_key() {
75
75
'Content-Type ' => 'application/json ' ,
76
76
'Authorization ' => 'abcd ' .str_repeat ('* ' , 36 )
77
77
);
78
- $ this ->assertTrue (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' , true ) == $ expected );
78
+
79
+ $ this ->assertEquals (NSA ::invokeMethod ($ this ->mailer , 'get_request_headers ' , true ), $ expected );
79
80
}
80
81
81
82
function test_get_headers () {
82
- $ raw_headers = "Date: Wed, 26 Oct 2016 23:45:32 +0000
83
- To: undisclosed-recipients:;
84
- From: Root User <root@localhost>
85
- Subject: Hello
86
- Reply-To: replyto@mydomain.com
87
- Message-ID: <abcd@example.org>
88
- MIME-Version: 1.0
89
- Content-Type: text/plain; charset=iso-8859-1
90
- Content-Transfer-Encoding: 8bit " ;
83
+ $ stub = Mockery::mock ($ this ->mailer );
84
+ $ raw_headers = join (
85
+ NSA ::getProperty ($ stub , 'LE ' ),
86
+ array (
87
+ 'Date: Wed, 26 Oct 2016 23:45:32 +0000 ' ,
88
+ 'To: undisclosed-recipients:; ' ,
89
+ 'From: Root User <root@localhost> ' ,
90
+ 'Subject: Hello ' ,
91
+ 'Reply-To: replyto@mydomain.com ' ,
92
+ 'Message-ID: <abcd@example.org> ' ,
93
+ 'MIME-Version: 1.0 ' ,
94
+ 'Content-Type: text/plain; charset=iso-8859-1 ' ,
95
+ 'Content-Transfer-Encoding: 8bit '
96
+ )
97
+ );
98
+ $ stub ->shouldReceive ('createHeader ' )->andReturn ($ raw_headers );
99
+ $ formatted_headers = NSA ::invokeMethod ($ stub , 'get_headers ' );
91
100
92
101
$ expected = array (
93
102
'Message-ID ' => '<abcd@example.org> ' ,
94
103
'Date ' => 'Wed, 26 Oct 2016 23:45:32 +0000 '
95
104
);
96
- $ stub = Mockery::mock ($ this ->mailer );
97
- $ stub ->shouldReceive ('createHeader ' )->andReturn ($ raw_headers );
98
- $ formatted_headers = NSA ::invokeMethod ($ stub , 'get_headers ' );
99
105
100
- $ this ->assertTrue ($ formatted_headers == $ expected );
106
+ $ this ->assertEquals ($ formatted_headers, $ expected );
101
107
}
102
108
103
109
104
110
function test_get_headers_should_include_cc_if_exists () {
105
- $ raw_headers = "Date: Wed, 26 Oct 2016 23:45:32 +0000
106
- Reply-To: replyto@mydomain.com " ;
107
-
108
- $ expected = array (
109
- 'Date ' => 'Wed, 26 Oct 2016 23:45:32 +0000 ' ,
110
- 'CC ' => 'hello@abc.com,Name <name@domain.com> '
111
- );
112
111
$ stub = Mockery::mock ($ this ->mailer );
112
+ $ raw_headers = join (
113
+ NSA ::getProperty ($ stub , 'LE ' ),
114
+ array (
115
+ 'Date: Wed, 26 Oct 2016 23:45:32 +0000 ' ,
116
+ 'Reply-To: replyto@mydomain.com '
117
+ )
118
+ );
113
119
$ stub ->shouldReceive ('createHeader ' )->andReturn ($ raw_headers );
114
120
$ stub ->addCc ('hello@abc.com ' );
115
121
$ stub ->addCc ('name@domain.com ' , 'Name ' );
116
122
117
123
$ formatted_headers = NSA ::invokeMethod ($ stub , 'get_headers ' );
118
124
119
- $ this ->assertTrue ($ formatted_headers == $ expected );
125
+ $ expected = array (
126
+ 'Date ' => 'Wed, 26 Oct 2016 23:45:32 +0000 ' ,
127
+ 'CC ' => 'hello@abc.com,Name <name@domain.com> '
128
+ );
129
+
130
+ $ this ->assertEquals ($ formatted_headers , $ expected );
120
131
}
121
132
122
133
function test_get_recipients () {
@@ -172,7 +183,7 @@ function test_get_recipients() {
172
183
];
173
184
174
185
$ recipients = NSA ::invokeMethod ($ this ->mailer , 'get_recipients ' );
175
- $ this ->assertTrue ($ recipients == $ expected );
186
+ $ this ->assertEquals ($ recipients, $ expected );
176
187
}
177
188
178
189
function test_get_attachments () {
@@ -190,9 +201,9 @@ function test_get_attachments() {
190
201
function test_isMail () {
191
202
// test if isMail sets correct mailer
192
203
$ this ->mailer ->Mailer = 'abc ' ;
193
- $ this ->assertTrue ($ this ->mailer ->Mailer === 'abc ' );
204
+ $ this ->assertEquals ($ this ->mailer ->Mailer , 'abc ' );
194
205
$ this ->mailer ->isMail ();
195
- $ this ->assertTrue ($ this ->mailer ->Mailer === 'sparkpost ' );
206
+ $ this ->assertEquals ($ this ->mailer ->Mailer , 'sparkpost ' );
196
207
}
197
208
198
209
function test_get_request_body_without_template () {
@@ -250,15 +261,15 @@ function test_get_request_body_without_template() {
250
261
// for simpler expectation reset content.headers to empty array.
251
262
// alternative is to stub get_headers which isn't working expectedly
252
263
$ actual ['content ' ]['headers ' ] = [];
253
- $ this ->assertTrue ($ expected_request_body == $ actual );
264
+ $ this ->assertEquals ($ expected_request_body, $ actual );
254
265
255
266
//INCLUDE REPLYTO
256
267
$ this ->mailer ->addReplyTo ('reply@abc.com ' , 'reply-to ' );
257
268
$ this ->mailer ->addCustomHeader ('Reply-To ' , 'reply-to <reply@abc.com> ' ); //for below version v4.6
258
269
$ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
259
270
$ actual ['content ' ]['headers ' ] = []; //see note above
260
271
$ expected_request_body ['content ' ]['reply_to ' ] = 'reply-to <reply@abc.com> ' ;
261
- $ this ->assertTrue ($ expected_request_body == $ actual );
272
+ $ this ->assertEquals ($ expected_request_body, $ actual );
262
273
}
263
274
264
275
function test_get_request_body_template_in_hook_but_not_in_settings () {
@@ -279,7 +290,7 @@ function test_get_request_body_template_in_hook_but_not_in_settings() {
279
290
280
291
$ body = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
281
292
remove_filter ('wpsp_template_id ' , $ callback );
282
- $ this ->assertTrue ($ body ['content ' ]['template_id ' ] == 'test-template ' );
293
+ $ this ->assertEquals ($ body ['content ' ]['template_id ' ], 'test-template ' );
283
294
}
284
295
285
296
function test_get_request_body_with_template () {
@@ -333,14 +344,14 @@ function test_get_request_body_with_template() {
333
344
];
334
345
335
346
$ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
336
- $ this ->assertTrue ($ expected_request_body == $ actual );
347
+ $ this ->assertEquals ($ expected_request_body, $ actual );
337
348
338
349
//INCLUDE REPLYTO
339
350
$ this ->mailer ->addReplyTo ('reply@abc.com ' , 'reply-to ' );
340
351
$ this ->mailer ->addCustomHeader ('Reply-To ' , 'reply-to <reply@abc.com> ' ); //for below version v4.6
341
352
$ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
342
353
$ expected_request_body ['substitution_data ' ]['reply_to ' ] = 'reply-to <reply@abc.com> ' ;
343
- $ this ->assertTrue ($ expected_request_body == $ actual );
354
+ $ this ->assertEquals ($ expected_request_body, $ actual );
344
355
}
345
356
346
357
function test_get_request_body_with_template_and_attachments () {
@@ -420,7 +431,7 @@ function test_get_request_body_with_template_and_attachments() {
420
431
421
432
$ actual = NSA ::invokeMethod ($ mailer , 'get_request_body ' );
422
433
unset($ actual ['content ' ]['headers ' ]); //to simplify assertion
423
- $ this ->assertTrue ($ expected_request_body == $ actual );
434
+ $ this ->assertEquals ($ expected_request_body, $ actual );
424
435
}
425
436
426
437
function test_sparkpost_send_false_on_error () {
@@ -519,7 +530,7 @@ function test_get_request_body_with_sandbox() {
519
530
]);
520
531
521
532
$ body = NSA ::invokeMethod ($ mailer , 'get_request_body ' );
522
- $ this ->assertTrue ($ body ['options ' ]['sandbox ' ] == true );
533
+ $ this ->assertTrue ($ body ['options ' ]['sandbox ' ]);
523
534
}
524
535
525
536
function sparkpost_send_prepare_mocks ($ num_rejected ) {
@@ -658,10 +669,10 @@ function test_check_permission_error(){
658
669
->setMethods (array ('debug ' , 'error ' ))
659
670
->getMock ();
660
671
661
- $ this ->assertTrue ($ mailer ->check_permission_error ($ response , 'test_perm ' ) === true );
672
+ $ this ->assertTrue ($ mailer ->check_permission_error ($ response , 'test_perm ' ));
662
673
663
674
$ response ['response ' ]['code ' ] = 200 ;
664
- $ this ->assertTrue ($ mailer ->check_permission_error ($ response , 'test_perm ' ) === false );
675
+ $ this ->assertFalse ($ mailer ->check_permission_error ($ response , 'test_perm ' ));
665
676
}
666
677
667
678
0 commit comments