|
3 | 3 | /**
|
4 | 4 | * conjoon
|
5 | 5 | * php-lib-conjoon
|
6 |
| - * Copyright (C) 2019-2022 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon |
| 6 | + * Copyright (C) 2019-2023 Thorsten Suckow-Homberg https://github.com/conjoon/php-lib-conjoon |
7 | 7 | *
|
8 | 8 | * Permission is hereby granted, free of charge, to any person
|
9 | 9 | * obtaining a copy of this software and associated documentation
|
@@ -164,4 +164,41 @@ public function testCopy()
|
164 | 164 | $this->assertSame($address1->getName(), $mailAddress->getName());
|
165 | 165 | $this->assertNotSame($address1, $mailAddress);
|
166 | 166 | }
|
| 167 | + |
| 168 | + |
| 169 | + /** |
| 170 | + * @see conjoon/php-lib-conjoon#12 |
| 171 | + */ |
| 172 | + public function testForAddressThatNeedToBeSanitized() |
| 173 | + { |
| 174 | + $tests = [ |
| 175 | + [ |
| 176 | + [ "Parker, Peter", "[email protected]"], |
| 177 | + [ "\"Parker, Peter\"", "[email protected]"], |
| 178 | + ], |
| 179 | + [ |
| 180 | + [ "Parker Peter", "[email protected]"], |
| 181 | + [ "Parker Peter", "[email protected]"], |
| 182 | + ], |
| 183 | + [ |
| 184 | + [ "Parker \" Peter", "[email protected]"], |
| 185 | + [ "\"Parker \\\" Peter\"", "[email protected]"], |
| 186 | + ], |
| 187 | + [ |
| 188 | + [ "Parker ' Peter", "[email protected]"], |
| 189 | + [ "\"Parker \' Peter\"", "[email protected]"], |
| 190 | + ], |
| 191 | + [ |
| 192 | + [ "Parker \"Parker, Peter Peter", "[email protected]"], |
| 193 | + [ "\"Parker \\\"Parker, Peter Peter\"", "[email protected]"], |
| 194 | + ] |
| 195 | + ]; |
| 196 | + |
| 197 | + foreach ($tests as $test) { |
| 198 | + [$input, $output] = $test; |
| 199 | + $mailAddress = new MailAddress($input[1], $input[0]); |
| 200 | + $this->assertSame($output[1], $mailAddress->getAddress()); |
| 201 | + $this->assertSame($output[0], $mailAddress->getName()); |
| 202 | + } |
| 203 | + } |
167 | 204 | }
|
0 commit comments