@@ -203,7 +203,8 @@ function test_get_request_body_without_template() {
203203
204204 NSA ::setProperty ($ this ->mailer , 'settings ' , [
205205 'enable_tracking ' => true ,
206- 'transactional ' => false
206+ 'transactional ' => false ,
207+ 'template ' => ''
207208 ]);
208209
209210 $ header_to = 'abc <abc@xyz.com> ' ;
@@ -259,6 +260,27 @@ function test_get_request_body_without_template() {
259260 $ this ->assertTrue ($ expected_request_body == $ actual );
260261 }
261262
263+ function test_get_request_body_template_in_hook_but_not_in_settings () {
264+ $ this ->mailer ->addAddress ('abc@xyz.com ' , 'abc ' );
265+ $ this ->mailer ->setFrom ( 'me@hello.com ' , 'me ' );
266+
267+ $ callback = function (){
268+ return 'test-template ' ;
269+ };
270+
271+ add_filter ('wpsp_template_id ' , $ callback );
272+
273+ NSA ::setProperty ($ this ->mailer , 'settings ' , [
274+ 'enable_tracking ' => true ,
275+ 'transactional ' => false ,
276+ 'template ' => ''
277+ ]);
278+
279+ $ body = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
280+ remove_filter ('wpsp_template_id ' , $ callback );
281+ $ this ->assertTrue ($ body ['content ' ]['template_id ' ] == 'test-template ' );
282+ }
283+
262284 function test_get_request_body_with_template () {
263285 $ this ->mailer ->addAddress ('abc@xyz.com ' , 'abc ' );
264286 $ this ->mailer ->addBcc ('bcc@xyz.com ' , 'bcc ' );
@@ -304,7 +326,7 @@ function test_get_request_body_with_template() {
304326 'content ' => '' ,
305327 'subject ' => '' ,
306328 'from_name ' => 'me ' ,
307- 'from ' => 'me <me @hello.com> ' ,
329+ 'from ' => 'me@hello.com ' ,
308330 'from_localpart ' => 'me '
309331 ]
310332 ];
0 commit comments