1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-18 02:41:24 +02:00

Merge branch '1.x'

This commit is contained in:
Jordi Boggiano
2017-06-19 02:16:33 +02:00
11 changed files with 66 additions and 27 deletions

View File

@@ -25,8 +25,13 @@ class ChromePHPHandlerTest extends TestCase
$_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0';
}
public function testHeaders()
/**
* @dataProvider agentsProvider
*/
public function testHeaders($agent)
{
$_SERVER['HTTP_USER_AGENT'] = $agent;
$handler = new TestChromePHPHandler();
$handler->setFormatter($this->getIdentityFormatter());
$handler->handle($this->getRecord(Logger::DEBUG));
@@ -47,6 +52,16 @@ class ChromePHPHandlerTest extends TestCase
$this->assertEquals($expected, $handler->getHeaders());
}
public static function agentsProvider()
{
return array(
array('Monolog Test; Chrome/1.0'),
array('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'),
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36'),
array('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36'),
);
}
public function testHeadersOverflow()
{
$handler = new TestChromePHPHandler();

View File

@@ -53,13 +53,20 @@ class DynamoDbHandlerTest extends TestCase
$handler = new DynamoDbHandler($this->client, 'foo');
$handler->setFormatter($formatter);
$isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
if ($isV3) {
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
} else {
$expFormatted = $formatted;
}
$formatter
->expects($this->once())
->method('format')
->with($record)
->will($this->returnValue($formatted));
$this->client
->expects($this->once())
->expects($isV3 ? $this->never() : $this->once())
->method('formatAttributes')
->with($this->isType('array'))
->will($this->returnValue($formatted));
@@ -68,7 +75,7 @@ class DynamoDbHandlerTest extends TestCase
->method('__call')
->with('putItem', [[
'TableName' => 'foo',
'Item' => $formatted,
'Item' => $expFormatted,
]]);
$handler->handle($record);

View File

@@ -102,11 +102,11 @@ class RotatingFileHandlerTest extends TestCase
$dayCallback = function ($ago) use ($now) {
return $now + 86400 * $ago;
};
$monthCallback = function ($ago) {
return gmmktime(0, 0, 0, (int) (date('n') + $ago), (int) date('d'), (int) date('Y'));
$monthCallback = function($ago) {
return gmmktime(0, 0, 0, (int) (date('n') + $ago), 1, (int) date('Y'));
};
$yearCallback = function ($ago) {
return gmmktime(0, 0, 0, (int) date('n'), (int) date('d'), (int) (date('Y') + $ago));
$yearCallback = function($ago) {
return gmmktime(0, 0, 0, 1, 1, (int) (date('Y') + $ago));
};
return [

View File

@@ -99,7 +99,7 @@ class SwiftMailerHandlerTest extends TestCase
public function testMessageHaveUniqueId()
{
$messageTemplate = \Swift_Message::newInstance();
$messageTemplate = new \Swift_Message();
$handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
$method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage');