2013-10-31 09:41:00 +01:00
|
|
|
<?php
|
|
|
|
|
2014-09-30 14:24:28 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the Monolog package.
|
|
|
|
*
|
|
|
|
* (c) Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2013-10-31 09:41:00 +01:00
|
|
|
namespace Monolog\Handler;
|
|
|
|
|
|
|
|
use Monolog\TestCase;
|
|
|
|
|
2014-08-14 16:34:32 +02:00
|
|
|
/**
|
|
|
|
* @requires extension sockets
|
|
|
|
*/
|
2013-10-31 09:41:00 +01:00
|
|
|
class UdpSocketTest extends TestCase
|
|
|
|
{
|
2014-12-17 10:46:48 +00:00
|
|
|
public function testWeDoNotTruncateShortMessages()
|
2013-10-31 09:41:00 +01:00
|
|
|
{
|
2013-10-31 11:06:45 +01:00
|
|
|
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
2013-10-31 09:41:00 +01:00
|
|
|
|
|
|
|
$socket->expects($this->at(0))
|
|
|
|
->method('send')
|
|
|
|
->with("HEADER: The quick brown fox jumps over the lazy dog");
|
|
|
|
|
|
|
|
$socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
|
|
|
|
}
|
|
|
|
|
2014-12-17 10:46:48 +00:00
|
|
|
public function testLongMessagesAreTruncated()
|
2013-10-31 09:41:00 +01:00
|
|
|
{
|
2013-10-31 11:06:45 +01:00
|
|
|
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
2013-10-31 09:41:00 +01:00
|
|
|
|
2014-12-17 10:46:48 +00:00
|
|
|
$truncatedString = str_repeat("derp", 16254).'d';
|
2013-10-31 09:41:00 +01:00
|
|
|
|
2014-12-17 10:46:48 +00:00
|
|
|
$socket->expects($this->exactly(1))
|
2013-10-31 09:41:00 +01:00
|
|
|
->method('send')
|
2014-12-17 10:46:48 +00:00
|
|
|
->with("HEADER" . $truncatedString);
|
2013-10-31 09:41:00 +01:00
|
|
|
|
2014-12-17 10:46:48 +00:00
|
|
|
$longString = str_repeat("derp", 20000);
|
2013-10-31 09:41:00 +01:00
|
|
|
|
2014-12-17 10:46:48 +00:00
|
|
|
$socket->write($longString, "HEADER");
|
2013-10-31 09:41:00 +01:00
|
|
|
}
|
|
|
|
}
|