mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-01 10:50:21 +02:00
Undo this LocalSocket fiasco, fix tests for latest phpunit
This commit is contained in:
@@ -13,7 +13,6 @@ namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Test\TestCase;
|
||||
use Monolog\Handler\SyslogUdp\UdpSocket;
|
||||
use Monolog\Util\LocalSocket;
|
||||
|
||||
/**
|
||||
* @requires extension sockets
|
||||
@@ -22,25 +21,34 @@ class UdpSocketTest extends TestCase
|
||||
{
|
||||
public function testWeDoNotTruncateShortMessages()
|
||||
{
|
||||
$this->initSocket();
|
||||
$socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket')
|
||||
->setMethods(['send'])
|
||||
->setConstructorArgs(['lol', 'lol'])
|
||||
->getMock();
|
||||
|
||||
$socket->expects($this->at(0))
|
||||
->method('send')
|
||||
->with("HEADER: The quick brown fox jumps over the lazy dog");
|
||||
|
||||
$socket = new UdpSocket('127.0.0.1', 51983);
|
||||
$socket->write("The quick brown fox jumps over the lazy dog", "HEADER: ");
|
||||
|
||||
$this->assertEquals('HEADER: The quick brown fox jumps over the lazy dog', $this->socket->getOutput());
|
||||
}
|
||||
|
||||
public function testLongMessagesAreTruncated()
|
||||
{
|
||||
$this->initSocket();
|
||||
|
||||
$socket = new UdpSocket('127.0.0.1', 51983);
|
||||
|
||||
$longString = str_repeat("derp", 20000);
|
||||
$socket->write($longString, "HEADER");
|
||||
$socket = $this->getMockBuilder('\Monolog\Handler\SyslogUdp\UdpSocket')
|
||||
->setMethods(['send'])
|
||||
->setConstructorArgs(['lol', 'lol'])
|
||||
->getMock();
|
||||
|
||||
$truncatedString = str_repeat("derp", 16254).'d';
|
||||
$this->assertEquals('HEADER'.$truncatedString, $this->socket->getOutput());
|
||||
|
||||
$socket->expects($this->exactly(1))
|
||||
->method('send')
|
||||
->with("HEADER" . $truncatedString);
|
||||
|
||||
$longString = str_repeat("derp", 20000);
|
||||
|
||||
$socket->write($longString, "HEADER");
|
||||
}
|
||||
|
||||
public function testDoubleCloseDoesNotError()
|
||||
@@ -59,14 +67,4 @@ class UdpSocketTest extends TestCase
|
||||
$socket->close();
|
||||
$socket->write('foo', "HEADER");
|
||||
}
|
||||
|
||||
private function initSocket()
|
||||
{
|
||||
$this->socket = LocalSocket::initSocket(51983, LocalSocket::UDP);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
unset($this->socket, $this->handler);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user