UdpSocketTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. /**
  13. * @requires extension sockets
  14. */
  15. class UdpSocketTest extends TestCase
  16. {
  17. public function testWeDoNotTruncateShortMessages()
  18. {
  19. $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
  20. $socket->expects($this->at(0))
  21. ->method('send')
  22. ->with("HEADER: The quick brown fox jumps over the lazy dog");
  23. $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
  24. }
  25. public function testLongMessagesAreTruncated()
  26. {
  27. $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
  28. $truncatedString = str_repeat("derp", 16254).'d';
  29. $socket->expects($this->exactly(1))
  30. ->method('send')
  31. ->with("HEADER" . $truncatedString);
  32. $longString = str_repeat("derp", 20000);
  33. $socket->write($longString, "HEADER");
  34. }
  35. }