1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 19:00:20 +02:00

Make sure SyslogUdpHandler does not create empty frames where not necessary, fixes #841

This commit is contained in:
Jordi Boggiano
2016-09-25 17:30:37 +02:00
parent 9f8d34afae
commit 40b4891030
2 changed files with 18 additions and 2 deletions

View File

@@ -11,10 +11,12 @@
namespace Monolog\Handler;
use Monolog\TestCase;
/**
* @requires extension sockets
*/
class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
class SyslogUdpHandlerTest extends TestCase
{
/**
* @expectedException UnexpectedValueException
@@ -42,6 +44,20 @@ class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
$handler->handle($this->getRecordWithMessage("hej\nlol"));
}
public function testSplitWorksOnEmptyMsg()
{
$handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
$handler->setFormatter($this->getIdentityFormatter());
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
$socket->expects($this->never())
->method('write');
$handler->setSocket($socket);
$handler->handle($this->getRecordWithMessage(null));
}
protected function getRecordWithMessage($msg)
{
return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');