mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 23:54:04 +02:00
Merge remote-tracking branch 'official/master' into gelf-php-compat
Conflicts: composer.json
This commit is contained in:
@@ -150,6 +150,34 @@ class LineFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
));
|
||||
$this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message);
|
||||
}
|
||||
|
||||
public function testFormatShouldStripInlineLineBreaks()
|
||||
{
|
||||
$formatter = new LineFormatter(null, 'Y-m-d');
|
||||
$message = $formatter->format(
|
||||
array(
|
||||
'message' => "foo\nbar",
|
||||
'context' => array(),
|
||||
'extra' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertRegExp('/foo bar/', $message);
|
||||
}
|
||||
|
||||
public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet()
|
||||
{
|
||||
$formatter = new LineFormatter(null, 'Y-m-d', true);
|
||||
$message = $formatter->format(
|
||||
array(
|
||||
'message' => "foo\nbar",
|
||||
'context' => array(),
|
||||
'extra' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertRegExp('/foo\nbar/', $message);
|
||||
}
|
||||
}
|
||||
|
||||
class TestFoo
|
||||
|
@@ -12,7 +12,6 @@ class ScalarFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$data = array();
|
||||
$trace = $e->getTrace();
|
||||
array_shift($trace);
|
||||
foreach ($trace as $frame) {
|
||||
if (isset($frame['file'])) {
|
||||
$data[] = $frame['file'].':'.$frame['line'];
|
||||
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
class AmqpExchangeMock extends \AMQPExchange
|
||||
{
|
||||
protected $messages = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function publish($message, $routing_key, $params = 0, $attributes = array())
|
||||
{
|
||||
$this->messages[] = array($message, $routing_key, $params, $attributes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -32,7 +32,19 @@ class AmqpHandlerTest extends TestCase
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$exchange = $this->getExchange();
|
||||
$messages = array();
|
||||
|
||||
$exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
|
||||
$exchange->expects($this->once())
|
||||
->method('setName')
|
||||
->with('log')
|
||||
;
|
||||
$exchange->expects($this->any())
|
||||
->method('publish')
|
||||
->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) {
|
||||
$messages[] = array($message, $routing_key, $flags, $attributes);
|
||||
}))
|
||||
;
|
||||
|
||||
$handler = new AmqpHandler($exchange, 'log');
|
||||
|
||||
@@ -60,15 +72,9 @@ class AmqpHandlerTest extends TestCase
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
$messages = $exchange->getMessages();
|
||||
$this->assertCount(1, $messages);
|
||||
$messages[0][0] = json_decode($messages[0][0], true);
|
||||
unset($messages[0][0]['datetime']);
|
||||
$this->assertEquals($expected, $messages[0]);
|
||||
}
|
||||
|
||||
protected function getExchange()
|
||||
{
|
||||
return new AmqpExchangeMock();
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,9 @@ class DynamoDbHandlerTest extends TestCase
|
||||
$this->markTestSkipped('aws/aws-sdk-php not installed');
|
||||
}
|
||||
|
||||
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')->disableOriginalConstructor()->getMock();
|
||||
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
|
||||
->setMethods(array('formatAttributes', '__call'))
|
||||
->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
public function testConstruct()
|
||||
|
@@ -156,4 +156,12 @@ class HipChatHandlerTest extends TestCase
|
||||
|
||||
$this->handler->setFormatter($this->getIdentityFormatter());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testCreateWithTooLongName()
|
||||
{
|
||||
$hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere');
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ class MongoDBHandlerTest extends TestCase
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$mongo = $this->getMock('Mongo', array('selectCollection'));
|
||||
$mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false);
|
||||
$collection = $this->getMock('stdClass', array('save'));
|
||||
|
||||
$mongo->expects($this->once())
|
||||
|
@@ -16,16 +16,16 @@ class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testWeSplitIntoLines()
|
||||
{
|
||||
$handler = new SyslogUdpHandler("127.0.0.1", 514, "local5");
|
||||
$handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv");
|
||||
$handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter());
|
||||
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol'));
|
||||
$socket->expects($this->at(0))
|
||||
->method('write')
|
||||
->with("lol", "<172>: ");
|
||||
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">: ");
|
||||
$socket->expects($this->at(1))
|
||||
->method('write')
|
||||
->with("hej", "<172>: ");
|
||||
->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">: ");
|
||||
|
||||
$handler->setSocket($socket);
|
||||
|
||||
|
@@ -10,4 +10,6 @@
|
||||
*/
|
||||
|
||||
$loader = require __DIR__ . "/../vendor/autoload.php";
|
||||
$loader->add('Monolog\\', __DIR__);
|
||||
$loader->addPsr4('Monolog\\', __DIR__.'/Monolog');
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
Reference in New Issue
Block a user