@@ -309,6 +309,43 @@ public function testCastingToStringReturnsAllMultiHeaderValues()
309
309
$ this ->assertEquals ($ expected , $ string );
310
310
}
311
311
312
+ /**
313
+ * @test that toArray can take format parameter
314
+ * @link https://github.com/zendframework/zend-mail/pull/61
315
+ */
316
+ public function testToArrayFormatRaw ()
317
+ {
318
+ $ raw_subject = '=?ISO-8859-2?Q?PD=3A_My=3A_Go=B3?= =?ISO-8859-2?Q?blahblah?= ' ;
319
+ $ headers = new Mail \Headers ();
320
+ $ subject = Header \Subject::fromString ("Subject: $ raw_subject " );
321
+ $ headers ->addHeader ($ subject );
322
+ // default
323
+ $ array = $ headers ->toArray (Header \HeaderInterface::FORMAT_RAW );
324
+ $ expected = [
325
+ 'Subject ' => 'PD: My: Gołblahblah ' ,
326
+ ];
327
+ $ this ->assertEquals ($ expected , $ array );
328
+ }
329
+
330
+ /**
331
+ * @test that toArray can take format parameter
332
+ * @link https://github.com/zendframework/zend-mail/pull/61
333
+ */
334
+ public function testToArrayFormatEncoded ()
335
+ {
336
+ $ raw_subject = '=?ISO-8859-2?Q?PD=3A_My=3A_Go=B3?= =?ISO-8859-2?Q?blahblah?= ' ;
337
+ $ headers = new Mail \Headers ();
338
+ $ subject = Header \Subject::fromString ("Subject: $ raw_subject " );
339
+ $ headers ->addHeader ($ subject );
340
+
341
+ // encoded
342
+ $ array = $ headers ->toArray (Header \HeaderInterface::FORMAT_ENCODED );
343
+ $ expected = [
344
+ 'Subject ' => '=?UTF-8?Q?PD:=20My:=20Go=C5=82blahblah?= ' ,
345
+ ];
346
+ $ this ->assertEquals ($ expected , $ array );
347
+ }
348
+
312
349
public static function expectedHeaders ()
313
350
{
314
351
return [
0 commit comments