NativeMailerHandlerTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Monolog package.
  4. *
  5. * (c) Jordi Boggiano <j.boggiano@seld.be>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Monolog\Handler;
  11. use Monolog\TestCase;
  12. class NativeMailerHandlerTest extends TestCase
  13. {
  14. /**
  15. * @expectedException InvalidArgumentException
  16. */
  17. public function testConstructorHeaderInjection()
  18. {
  19. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org");
  20. }
  21. /**
  22. * @expectedException InvalidArgumentException
  23. */
  24. public function testSetterHeaderInjection()
  25. {
  26. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
  27. $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org");
  28. }
  29. /**
  30. * @expectedException InvalidArgumentException
  31. */
  32. public function testSetterArrayHeaderInjection()
  33. {
  34. $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
  35. $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
  36. }
  37. }