@@ -139,26 +139,26 @@ function test_get_recipients() {
139139 ],
140140 [
141141 'address ' => [
142- 'email ' => 'bcc@abc.com ' ,
143- 'header_to ' => $ header_to
142+ 'email ' => 'bcc@abc.com ' ,
143+ 'header_to ' => $ header_to
144144 ]
145145 ],
146146 [
147147 'address ' => [
148- 'email ' => 'bcc1@abc.com ' ,
149- 'header_to ' => $ header_to
148+ 'email ' => 'bcc1@abc.com ' ,
149+ 'header_to ' => $ header_to
150150 ]
151151 ],
152152 [
153153 'address ' => [
154- 'email ' => 'cc@abc.com ' ,
155- 'header_to ' => $ header_to
154+ 'email ' => 'cc@abc.com ' ,
155+ 'header_to ' => $ header_to
156156 ]
157157 ],
158158 [
159159 'address ' => [
160- 'email ' => 'cc1@abc.com ' ,
161- 'header_to ' => $ header_to
160+ 'email ' => 'cc1@abc.com ' ,
161+ 'header_to ' => $ header_to
162162 ]
163163 ]
164164 ];
@@ -186,7 +186,7 @@ function test_isMail() {
186186 $ this ->assertTrue ($ this ->mailer ->Mailer === 'sparkpost ' );
187187 }
188188
189- function test_get_request_body () {
189+ function test_get_request_body_without_template () {
190190 // WITHOUT TEMPLATE
191191 $ this ->mailer ->addAddress ('abc@xyz.com ' , 'abc ' );
192192 $ this ->mailer ->addBcc ('bcc@xyz.com ' , 'bcc ' );
@@ -209,8 +209,8 @@ function test_get_request_body() {
209209 ],
210210 [
211211 'address ' => [
212- 'email ' => 'bcc@xyz.com ' ,
213- 'header_to ' => $ header_to
212+ 'email ' => 'bcc@xyz.com ' ,
213+ 'header_to ' => $ header_to
214214 ]
215215 ],
216216 [
@@ -221,18 +221,18 @@ function test_get_request_body() {
221221 ]
222222 ],
223223 'options ' => [
224- 'open_tracking ' => (bool ) true ,
225- 'click_tracking ' => (bool ) true ,
226- 'transactional ' => (bool ) false
224+ 'open_tracking ' => (bool ) true ,
225+ 'click_tracking ' => (bool ) true ,
226+ 'transactional ' => (bool ) false
227227 ],
228228 'content ' => [
229- 'from ' => [
230- 'name ' => 'me ' ,
231- 'email ' =>'me@hello.com '
232- ],
233- 'subject ' => '' ,
234- 'headers ' => [],
235- 'text ' => ''
229+ 'from ' => [
230+ 'name ' => 'me ' ,
231+ 'email ' =>'me@hello.com '
232+ ],
233+ 'subject ' => '' ,
234+ 'headers ' => [],
235+ 'text ' => ''
236236 ]
237237 ];
238238
@@ -242,25 +242,71 @@ function test_get_request_body() {
242242 $ actual ['content ' ]['headers ' ] = [];
243243 $ this ->assertTrue ($ expected_request_body == $ actual );
244244
245- //WITH TEMPLATE - reuse previous setup
245+ //INCLUDE REPLYTO
246+ $ this ->mailer ->addReplyTo ('reply@abc.com ' , 'reply-to ' );
247+ $ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
248+ $ actual ['content ' ]['headers ' ] = []; //see note above
249+ $ expected_request_body ['content ' ]['reply_to ' ] = 'reply-to <reply@abc.com> ' ;
250+ $ this ->assertTrue ($ expected_request_body == $ actual );
251+ }
252+
253+ function test_get_request_body_with_template () {
254+ $ this ->mailer ->addAddress ('abc@xyz.com ' , 'abc ' );
255+ $ this ->mailer ->addBcc ('bcc@xyz.com ' , 'bcc ' );
256+ $ this ->mailer ->addCc ('cc@xyz.com ' , 'cc ' );
257+ $ this ->mailer ->setFrom ( 'me@hello.com ' , 'me ' );
258+ $ header_to = 'abc <abc@xyz.com> ' ;
246259 NSA ::setProperty ($ this ->mailer , 'settings ' , [
247260 'enable_tracking ' => true ,
248261 'transactional ' => false ,
249262 'template ' => 'hello '
250263 ]);
251264
252- $ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
253- $ expected_request_body ['content ' ] = [
254- 'template_id ' => 'hello ' ,
255- ];
256- $ expected_request_body ['substitution_data ' ] = [
257- 'content ' => '' ,
258- 'subject ' => '' ,
259- 'from_name ' => 'me ' ,
260- 'from ' => 'me <me@hello.com> ' ,
261- 'from_localpart ' => 'me '
265+ $ expected_request_body = [
266+ 'recipients ' => [
267+ [
268+ 'address ' => [
269+ 'email ' => 'abc@xyz.com ' ,
270+ 'header_to ' => $ header_to
271+ ]
272+ ],
273+ [
274+ 'address ' => [
275+ 'email ' => 'bcc@xyz.com ' ,
276+ 'header_to ' => $ header_to
277+ ]
278+ ],
279+ [
280+ 'address ' => [
281+ 'email ' => 'cc@xyz.com ' ,
282+ 'header_to ' => $ header_to
283+ ]
284+ ]
285+ ],
286+ 'options ' => [
287+ 'open_tracking ' => (bool ) true ,
288+ 'click_tracking ' => (bool ) true ,
289+ 'transactional ' => (bool ) false
290+ ],
291+ 'content ' => [
292+ 'template_id ' => 'hello ' ,
293+ ],
294+ 'substitution_data ' => [
295+ 'content ' => '' ,
296+ 'subject ' => '' ,
297+ 'from_name ' => 'me ' ,
298+ 'from ' => 'me <me@hello.com> ' ,
299+ 'from_localpart ' => 'me '
300+ ]
262301 ];
263-
302+
303+ $ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
304+ $ this ->assertTrue ($ expected_request_body == $ actual );
305+
306+ //INCLUDE REPLYTO
307+ $ this ->mailer ->addReplyTo ('reply@abc.com ' , 'reply-to ' );
308+ $ actual = NSA ::invokeMethod ($ this ->mailer , 'get_request_body ' );
309+ $ expected_request_body ['substitution_data ' ]['reply_to ' ] = 'reply-to <reply@abc.com> ' ;
264310 $ this ->assertTrue ($ expected_request_body == $ actual );
265311 }
266312}
0 commit comments