mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-23 13:23:08 +02:00
CS fixes
This commit is contained in:
@@ -25,7 +25,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructAndGetSet()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', [Logger::WARNING, false]);
|
||||
$this->assertEquals(Logger::WARNING, $handler->getLevel());
|
||||
$this->assertEquals(false, $handler->getBubble());
|
||||
|
||||
@@ -43,7 +43,7 @@ class AbstractHandlerTest extends TestCase
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler');
|
||||
$handler->expects($this->exactly(2))
|
||||
->method('handle');
|
||||
$handler->handleBatch(array($this->getRecord(), $this->getRecord()));
|
||||
$handler->handleBatch([$this->getRecord(), $this->getRecord()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsHandling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', [Logger::WARNING, false]);
|
||||
$this->assertTrue($handler->isHandling($this->getRecord()));
|
||||
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class AbstractHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandlesPsrStyleLevels()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array('warning', false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', ['warning', false]);
|
||||
$this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
||||
$handler->setLevel('debug');
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
|
||||
|
@@ -24,7 +24,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructAndGetSet()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Logger::WARNING, false]);
|
||||
$handler->setFormatter($formatter = new LineFormatter);
|
||||
$this->assertSame($formatter, $handler->getFormatter());
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleLowerLevelMessage()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Logger::WARNING, true]);
|
||||
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBubbling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Logger::DEBUG, true]);
|
||||
$this->assertFalse($handler->handle($this->getRecord()));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleNotBubbling()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Logger::DEBUG, false]);
|
||||
$this->assertTrue($handler->handle($this->getRecord()));
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleIsFalseWhenNotHandled()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false));
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', [Logger::WARNING, false]);
|
||||
$this->assertTrue($handler->handle($this->getRecord()));
|
||||
$this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG)));
|
||||
}
|
||||
@@ -72,13 +72,13 @@ class AbstractProcessingHandlerTest extends TestCase
|
||||
public function testProcessRecord()
|
||||
{
|
||||
$handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler');
|
||||
$handler->pushProcessor(new WebProcessor(array(
|
||||
$handler->pushProcessor(new WebProcessor([
|
||||
'REQUEST_URI' => '',
|
||||
'REQUEST_METHOD' => '',
|
||||
'REMOTE_ADDR' => '',
|
||||
'SERVER_NAME' => '',
|
||||
'UNIQUE_ID' => '',
|
||||
)));
|
||||
]));
|
||||
$handledRecord = null;
|
||||
$handler->expects($this->once())
|
||||
->method('write')
|
||||
|
@@ -31,43 +31,43 @@ class AmqpHandlerTest extends TestCase
|
||||
$this->markTestSkipped("Please update AMQP to version >= 1.0");
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
$exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false);
|
||||
$exchange = $this->getMock('AMQPExchange', ['publish', 'setName'], [], '', 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);
|
||||
->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = []) use (&$messages) {
|
||||
$messages[] = [$message, $routing_key, $flags, $attributes];
|
||||
}))
|
||||
;
|
||||
|
||||
$handler = new AmqpHandler($exchange, 'log');
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
$expected = [
|
||||
[
|
||||
'message' => 'test',
|
||||
'context' => array(
|
||||
'data' => array(),
|
||||
'context' => [
|
||||
'data' => [],
|
||||
'foo' => 34,
|
||||
),
|
||||
],
|
||||
'level' => 300,
|
||||
'level_name' => 'WARNING',
|
||||
'channel' => 'test',
|
||||
'extra' => array(),
|
||||
),
|
||||
'extra' => [],
|
||||
],
|
||||
'warning.test',
|
||||
0,
|
||||
array(
|
||||
[
|
||||
'delivery_mode' => 2,
|
||||
'content_type' => 'application/json',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
@@ -83,43 +83,43 @@ class AmqpHandlerTest extends TestCase
|
||||
$this->markTestSkipped("php-amqplib not installed");
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
|
||||
$exchange = $this->getMock('PhpAmqpLib\Channel\AMQPChannel', array('basic_publish', '__destruct'), array(), '', false);
|
||||
$exchange = $this->getMock('PhpAmqpLib\Channel\AMQPChannel', ['basic_publish', '__destruct'], [], '', false);
|
||||
|
||||
$exchange->expects($this->any())
|
||||
->method('basic_publish')
|
||||
->will($this->returnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) {
|
||||
$messages[] = array($msg, $exchange, $routing_key, $mandatory, $immediate, $ticket);
|
||||
$messages[] = [$msg, $exchange, $routing_key, $mandatory, $immediate, $ticket];
|
||||
}))
|
||||
;
|
||||
|
||||
$handler = new AmqpHandler($exchange, 'log');
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
$expected = [
|
||||
[
|
||||
'message' => 'test',
|
||||
'context' => array(
|
||||
'data' => array(),
|
||||
'context' => [
|
||||
'data' => [],
|
||||
'foo' => 34,
|
||||
),
|
||||
],
|
||||
'level' => 300,
|
||||
'level_name' => 'WARNING',
|
||||
'channel' => 'test',
|
||||
'extra' => array(),
|
||||
),
|
||||
'extra' => [],
|
||||
],
|
||||
'log',
|
||||
'warning.test',
|
||||
false,
|
||||
false,
|
||||
null,
|
||||
array(
|
||||
[
|
||||
'delivery_mode' => 2,
|
||||
'content_type' => 'application/json',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
|
@@ -89,7 +89,7 @@ EOF;
|
||||
$handler = new BrowserConsoleHandler();
|
||||
$handler->setFormatter($this->getIdentityFormatter());
|
||||
|
||||
$handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
|
||||
$handler->handle($this->getRecord(Logger::DEBUG, 'test', ['foo' => 'bar']));
|
||||
|
||||
$expected = <<<EOF
|
||||
(function (c) {if (c && c.groupCollapsed) {
|
||||
|
@@ -47,7 +47,7 @@ class BufferHandlerTest extends TestCase
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$this->shutdownCheckHandler = $test;
|
||||
register_shutdown_function(array($this, 'checkPropagation'));
|
||||
register_shutdown_function([$this, 'checkPropagation']);
|
||||
}
|
||||
|
||||
public function checkPropagation()
|
||||
|
@@ -32,17 +32,17 @@ class ChromePHPHandlerTest extends TestCase
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
|
||||
$expected = array(
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
||||
$expected = [
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([
|
||||
'version' => ChromePHPHandler::VERSION,
|
||||
'columns' => array('label', 'log', 'backtrace', 'type'),
|
||||
'rows' => array(
|
||||
'columns' => ['label', 'log', 'backtrace', 'type'],
|
||||
'rows' => [
|
||||
'test',
|
||||
'test',
|
||||
),
|
||||
],
|
||||
'request_uri' => '',
|
||||
)))),
|
||||
);
|
||||
]))),
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $handler->getHeaders());
|
||||
}
|
||||
@@ -56,33 +56,33 @@ class ChromePHPHandlerTest extends TestCase
|
||||
// overflow chrome headers limit
|
||||
$handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100 * 1024)));
|
||||
|
||||
$expected = array(
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
||||
$expected = [
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([
|
||||
'version' => ChromePHPHandler::VERSION,
|
||||
'columns' => array('label', 'log', 'backtrace', 'type'),
|
||||
'rows' => array(
|
||||
array(
|
||||
'columns' => ['label', 'log', 'backtrace', 'type'],
|
||||
'rows' => [
|
||||
[
|
||||
'test',
|
||||
'test',
|
||||
'unknown',
|
||||
'log',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'test',
|
||||
str_repeat('a', 150 * 1024),
|
||||
'unknown',
|
||||
'warn',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'monolog',
|
||||
'Incomplete logs, chrome header size limit reached',
|
||||
'unknown',
|
||||
'warn',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
'request_uri' => '',
|
||||
)))),
|
||||
);
|
||||
]))),
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $handler->getHeaders());
|
||||
}
|
||||
@@ -99,19 +99,19 @@ class ChromePHPHandlerTest extends TestCase
|
||||
$handler2->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler2->handle($this->getRecord(Logger::WARNING));
|
||||
|
||||
$expected = array(
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array(
|
||||
$expected = [
|
||||
'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode([
|
||||
'version' => ChromePHPHandler::VERSION,
|
||||
'columns' => array('label', 'log', 'backtrace', 'type'),
|
||||
'rows' => array(
|
||||
'columns' => ['label', 'log', 'backtrace', 'type'],
|
||||
'rows' => [
|
||||
'test',
|
||||
'test',
|
||||
'test',
|
||||
'test',
|
||||
),
|
||||
],
|
||||
'request_uri' => '',
|
||||
)))),
|
||||
);
|
||||
]))),
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $handler2->getHeaders());
|
||||
}
|
||||
@@ -119,14 +119,14 @@ class ChromePHPHandlerTest extends TestCase
|
||||
|
||||
class TestChromePHPHandler extends ChromePHPHandler
|
||||
{
|
||||
protected $headers = array();
|
||||
protected $headers = [];
|
||||
|
||||
public static function reset()
|
||||
{
|
||||
self::$initialized = false;
|
||||
self::$overflowed = false;
|
||||
self::$sendHeaders = true;
|
||||
self::$json['rows'] = array();
|
||||
self::$json['rows'] = [];
|
||||
}
|
||||
|
||||
protected function sendHeader($header, $content)
|
||||
|
@@ -18,7 +18,7 @@ class CouchDBHandlerTest extends TestCase
|
||||
{
|
||||
public function testHandle()
|
||||
{
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new CouchDBHandler();
|
||||
|
||||
|
@@ -26,21 +26,21 @@ class DoctrineCouchDBHandlerTest extends TestCase
|
||||
public function testHandle()
|
||||
{
|
||||
$client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient')
|
||||
->setMethods(array('postDocument'))
|
||||
->setMethods(['postDocument'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'message' => 'test',
|
||||
'context' => array('data' => ['stdClass' => []], 'foo' => 34),
|
||||
'context' => ['data' => ['stdClass' => []], 'foo' => 34],
|
||||
'level' => Logger::WARNING,
|
||||
'level_name' => 'WARNING',
|
||||
'channel' => 'test',
|
||||
'datetime' => (string) $record['datetime'],
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
|
||||
$client->expects($this->once())
|
||||
->method('postDocument')
|
||||
|
@@ -24,7 +24,7 @@ class DynamoDbHandlerTest extends TestCase
|
||||
}
|
||||
|
||||
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
|
||||
->setMethods(array('formatAttributes', '__call'))
|
||||
->setMethods(['formatAttributes', '__call'])
|
||||
->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class DynamoDbHandlerTest extends TestCase
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
$formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
|
||||
$formatted = array('foo' => 1, 'bar' => 2);
|
||||
$formatted = ['foo' => 1, 'bar' => 2];
|
||||
$handler = new DynamoDbHandler($this->client, 'foo');
|
||||
$handler->setFormatter($formatter);
|
||||
|
||||
@@ -65,10 +65,10 @@ class DynamoDbHandlerTest extends TestCase
|
||||
$this->client
|
||||
->expects($this->once())
|
||||
->method('__call')
|
||||
->with('putItem', array(array(
|
||||
->with('putItem', [[
|
||||
'TableName' => 'foo',
|
||||
'Item' => $formatted,
|
||||
)));
|
||||
]]);
|
||||
|
||||
$handler->handle($record);
|
||||
}
|
||||
|
@@ -29,10 +29,10 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
/**
|
||||
* @var array Default handler options
|
||||
*/
|
||||
protected $options = array(
|
||||
protected $options = [
|
||||
'index' => 'my_index',
|
||||
'type' => 'doc_type',
|
||||
);
|
||||
];
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
@@ -43,7 +43,7 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
|
||||
// base mock Elastica Client object
|
||||
$this->client = $this->getMockBuilder('Elastica\Client')
|
||||
->setMethods(array('addDocuments'))
|
||||
->setMethods(['addDocuments'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
@@ -57,19 +57,19 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
public function testHandle()
|
||||
{
|
||||
// log message
|
||||
$msg = array(
|
||||
$msg = [
|
||||
'level' => Logger::ERROR,
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
||||
'context' => ['foo' => 7, 'bar', 'class' => new \stdClass],
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'extra' => [],
|
||||
'message' => 'log',
|
||||
);
|
||||
];
|
||||
|
||||
// format expected result
|
||||
$formatter = new ElasticaFormatter($this->options['index'], $this->options['type']);
|
||||
$expected = array($formatter->format($msg));
|
||||
$expected = [$formatter->format($msg)];
|
||||
|
||||
// setup ES client mock
|
||||
$this->client->expects($this->any())
|
||||
@@ -79,7 +79,7 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
// perform tests
|
||||
$handler = new ElasticSearchHandler($this->client, $this->options);
|
||||
$handler->handle($msg);
|
||||
$handler->handleBatch(array($msg));
|
||||
$handler->handleBatch([$msg]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,11 +113,11 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
*/
|
||||
public function testOptions()
|
||||
{
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'index' => $this->options['index'],
|
||||
'type' => $this->options['type'],
|
||||
'ignore_error' => false,
|
||||
);
|
||||
];
|
||||
$handler = new ElasticSearchHandler($this->client, $this->options);
|
||||
$this->assertEquals($expected, $handler->getOptions());
|
||||
}
|
||||
@@ -128,9 +128,9 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConnectionErrors($ignore, $expectedError)
|
||||
{
|
||||
$clientOpts = array('host' => '127.0.0.1', 'port' => 1);
|
||||
$clientOpts = ['host' => '127.0.0.1', 'port' => 1];
|
||||
$client = new Client($clientOpts);
|
||||
$handlerOpts = array('ignore_error' => $ignore);
|
||||
$handlerOpts = ['ignore_error' => $ignore];
|
||||
$handler = new ElasticSearchHandler($client, $handlerOpts);
|
||||
|
||||
if ($expectedError) {
|
||||
@@ -146,10 +146,10 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
*/
|
||||
public function providerTestConnectionErrors()
|
||||
{
|
||||
return array(
|
||||
array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')),
|
||||
array(true, false),
|
||||
);
|
||||
return [
|
||||
[false, ['RuntimeException', 'Error sending messages to Elasticsearch']],
|
||||
[true, false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,28 +162,28 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleIntegration()
|
||||
{
|
||||
$msg = array(
|
||||
$msg = [
|
||||
'level' => Logger::ERROR,
|
||||
'level_name' => 'ERROR',
|
||||
'channel' => 'meh',
|
||||
'context' => array('foo' => 7, 'bar', 'class' => new \stdClass),
|
||||
'context' => ['foo' => 7, 'bar', 'class' => new \stdClass],
|
||||
'datetime' => new \DateTimeImmutable("@0"),
|
||||
'extra' => array(),
|
||||
'extra' => [],
|
||||
'message' => 'log',
|
||||
);
|
||||
];
|
||||
|
||||
$expected = $msg;
|
||||
$expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601);
|
||||
$expected['context'] = array(
|
||||
$expected['context'] = [
|
||||
'class' => '[object] (stdClass: {})',
|
||||
'foo' => 7,
|
||||
0 => 'bar',
|
||||
);
|
||||
];
|
||||
|
||||
$client = new Client();
|
||||
$handler = new ElasticSearchHandler($client, $this->options);
|
||||
try {
|
||||
$handler->handleBatch(array($msg));
|
||||
$handler->handleBatch([$msg]);
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
|
||||
}
|
||||
@@ -234,6 +234,6 @@ class ElasticSearchHandlerTest extends TestCase
|
||||
return $data['_source'];
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class ErrorLogHandlerTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['error_log'] = array();
|
||||
$GLOBALS['error_log'] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -63,7 +63,7 @@ class FilterHandlerTest extends TestCase
|
||||
$this->assertFalse($test->hasEmergencyRecords());
|
||||
|
||||
$test = new TestHandler();
|
||||
$handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR));
|
||||
$handler = new FilterHandler($test, [Logger::INFO, Logger::ERROR]);
|
||||
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$this->assertFalse($test->hasDebugRecords());
|
||||
@@ -86,14 +86,14 @@ class FilterHandlerTest extends TestCase
|
||||
$test = new TestHandler();
|
||||
$handler = new FilterHandler($test);
|
||||
|
||||
$levels = array(Logger::INFO, Logger::ERROR);
|
||||
$levels = [Logger::INFO, Logger::ERROR];
|
||||
$handler->setAcceptedLevels($levels);
|
||||
$this->assertSame($levels, $handler->getAcceptedLevels());
|
||||
|
||||
$handler->setAcceptedLevels(array('info', 'error'));
|
||||
$handler->setAcceptedLevels(['info', 'error']);
|
||||
$this->assertSame($levels, $handler->getAcceptedLevels());
|
||||
|
||||
$levels = array(Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY);
|
||||
$levels = [Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY];
|
||||
$handler->setAcceptedLevels(Logger::CRITICAL, Logger::EMERGENCY);
|
||||
$this->assertSame($levels, $handler->getAcceptedLevels());
|
||||
|
||||
|
@@ -203,7 +203,7 @@ class FingersCrossedHandlerTest extends TestCase
|
||||
public function testChannelLevelActivationStrategy()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG)));
|
||||
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, ['othertest' => Logger::DEBUG]));
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
$this->assertFalse($test->hasWarningRecords());
|
||||
$record = $this->getRecord(Logger::DEBUG);
|
||||
@@ -220,7 +220,7 @@ class FingersCrossedHandlerTest extends TestCase
|
||||
public function testChannelLevelActivationStrategyWithPsrLevels()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy('error', array('othertest' => 'debug')));
|
||||
$handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy('error', ['othertest' => 'debug']));
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
$this->assertFalse($test->hasWarningRecords());
|
||||
$record = $this->getRecord(Logger::DEBUG);
|
||||
|
@@ -32,13 +32,13 @@ class FirePHPHandlerTest extends TestCase
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
||||
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
||||
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
||||
'X-Wf-1-1-1-1' => 'test',
|
||||
'X-Wf-1-1-1-2' => 'test',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $handler->getHeaders());
|
||||
}
|
||||
@@ -55,18 +55,18 @@ class FirePHPHandlerTest extends TestCase
|
||||
$handler2->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler2->handle($this->getRecord(Logger::WARNING));
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2',
|
||||
'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1',
|
||||
'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3',
|
||||
'X-Wf-1-1-1-1' => 'test',
|
||||
'X-Wf-1-1-1-2' => 'test',
|
||||
);
|
||||
];
|
||||
|
||||
$expected2 = array(
|
||||
$expected2 = [
|
||||
'X-Wf-1-1-1-3' => 'test',
|
||||
'X-Wf-1-1-1-4' => 'test',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $handler->getHeaders());
|
||||
$this->assertEquals($expected2, $handler2->getHeaders());
|
||||
@@ -75,7 +75,7 @@ class FirePHPHandlerTest extends TestCase
|
||||
|
||||
class TestFirePHPHandler extends FirePHPHandler
|
||||
{
|
||||
protected $headers = array();
|
||||
protected $headers = [];
|
||||
|
||||
public static function reset()
|
||||
{
|
||||
|
@@ -56,15 +56,15 @@ class FleepHookHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays()
|
||||
{
|
||||
$record = array(
|
||||
$record = [
|
||||
'message' => 'msg',
|
||||
'context' => array(),
|
||||
'context' => [],
|
||||
'level' => Logger::DEBUG,
|
||||
'level_name' => Logger::getLevelName(Logger::DEBUG),
|
||||
'channel' => 'channel',
|
||||
'datetime' => new \DateTimeImmutable(),
|
||||
'extra' => array(),
|
||||
);
|
||||
'extra' => [],
|
||||
];
|
||||
|
||||
$expectedFormatter = new LineFormatter(null, null, true, true);
|
||||
$expected = $expectedFormatter->format($record);
|
||||
|
@@ -61,11 +61,11 @@ class FlowdockHandlerTest extends TestCase
|
||||
|
||||
private function createHandler($token = 'myToken')
|
||||
{
|
||||
$constructorArgs = array($token, Logger::DEBUG);
|
||||
$constructorArgs = [$token, Logger::DEBUG];
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\FlowdockHandler',
|
||||
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
||||
['fsockopen', 'streamSetTimeout', 'closeSocket'],
|
||||
$constructorArgs
|
||||
);
|
||||
|
||||
|
@@ -43,7 +43,7 @@ class GelfHandlerTest extends TestCase
|
||||
|
||||
protected function getMessagePublisher()
|
||||
{
|
||||
return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false);
|
||||
return $this->getMock('Gelf\Publisher', ['publish'], [], '', false);
|
||||
}
|
||||
|
||||
public function testDebug()
|
||||
|
@@ -22,7 +22,7 @@ class GroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructorOnlyTakesHandler()
|
||||
{
|
||||
new GroupHandler(array(new TestHandler(), "foo"));
|
||||
new GroupHandler([new TestHandler(), "foo"]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ class GroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandle()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(), new TestHandler());
|
||||
$testHandlers = [new TestHandler(), new TestHandler()];
|
||||
$handler = new GroupHandler($testHandlers);
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::INFO));
|
||||
@@ -47,9 +47,9 @@ class GroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBatch()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(), new TestHandler());
|
||||
$testHandlers = [new TestHandler(), new TestHandler()];
|
||||
$handler = new GroupHandler($testHandlers);
|
||||
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
||||
$handler->handleBatch([$this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)]);
|
||||
foreach ($testHandlers as $test) {
|
||||
$this->assertTrue($test->hasDebugRecords());
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
@@ -62,7 +62,7 @@ class GroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsHandling()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
|
||||
$testHandlers = [new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)];
|
||||
$handler = new GroupHandler($testHandlers);
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
|
||||
@@ -75,7 +75,7 @@ class GroupHandlerTest extends TestCase
|
||||
public function testHandleUsesProcessors()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new GroupHandler(array($test));
|
||||
$handler = new GroupHandler([$test]);
|
||||
$handler->pushProcessor(function ($record) {
|
||||
$record['extra']['foo'] = true;
|
||||
|
||||
|
@@ -37,10 +37,10 @@ class HandlerWrapperTest extends TestCase
|
||||
*/
|
||||
public function trueFalseDataProvider()
|
||||
{
|
||||
return array(
|
||||
array(true),
|
||||
array(false),
|
||||
);
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -139,16 +139,16 @@ class HipChatHandlerTest extends TestCase
|
||||
|
||||
public function provideLevelColors()
|
||||
{
|
||||
return array(
|
||||
array(Logger::DEBUG, 'gray'),
|
||||
array(Logger::INFO, 'green'),
|
||||
array(Logger::WARNING, 'yellow'),
|
||||
array(Logger::ERROR, 'red'),
|
||||
array(Logger::CRITICAL, 'red'),
|
||||
array(Logger::ALERT, 'red'),
|
||||
array(Logger::EMERGENCY,'red'),
|
||||
array(Logger::NOTICE, 'green'),
|
||||
);
|
||||
return [
|
||||
[Logger::DEBUG, 'gray'],
|
||||
[Logger::INFO, 'green'],
|
||||
[Logger::WARNING, 'yellow'],
|
||||
[Logger::ERROR, 'red'],
|
||||
[Logger::CRITICAL, 'red'],
|
||||
[Logger::ALERT, 'red'],
|
||||
[Logger::EMERGENCY,'red'],
|
||||
[Logger::NOTICE, 'green'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,45 +168,45 @@ class HipChatHandlerTest extends TestCase
|
||||
|
||||
public function provideBatchRecords()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
return [
|
||||
[
|
||||
[
|
||||
['level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()],
|
||||
['level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()],
|
||||
['level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTimeImmutable()],
|
||||
],
|
||||
'red',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
],
|
||||
[
|
||||
[
|
||||
['level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTimeImmutable()],
|
||||
['level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()],
|
||||
],
|
||||
'yellow',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()),
|
||||
array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
],
|
||||
[
|
||||
[
|
||||
['level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()],
|
||||
['level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTimeImmutable()],
|
||||
],
|
||||
'green',
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()),
|
||||
),
|
||||
],
|
||||
[
|
||||
[
|
||||
['level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTimeImmutable()],
|
||||
],
|
||||
'gray',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com', $version = 'v1')
|
||||
{
|
||||
$constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version);
|
||||
$constructorArgs = [$token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version];
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\HipChatHandler',
|
||||
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
||||
['fsockopen', 'streamSetTimeout', 'closeSocket'],
|
||||
$constructorArgs
|
||||
);
|
||||
|
||||
|
@@ -42,11 +42,11 @@ class LogEntriesHandlerTest extends TestCase
|
||||
|
||||
public function testWriteBatchContent()
|
||||
{
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(),
|
||||
$this->getRecord(),
|
||||
$this->getRecord(),
|
||||
);
|
||||
];
|
||||
$this->createHandler();
|
||||
$this->handler->handleBatch($records);
|
||||
|
||||
@@ -59,11 +59,11 @@ class LogEntriesHandlerTest extends TestCase
|
||||
private function createHandler()
|
||||
{
|
||||
$useSSL = extension_loaded('openssl');
|
||||
$args = array('testToken', $useSSL, Logger::DEBUG, true);
|
||||
$args = ['testToken', $useSSL, Logger::DEBUG, true];
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\LogEntriesHandler',
|
||||
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
||||
['fsockopen', 'streamSetTimeout', 'closeSocket'],
|
||||
$args
|
||||
);
|
||||
|
||||
|
@@ -41,11 +41,11 @@ class MailHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
|
||||
{
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
||||
$this->getRecord(Logger::INFO, 'information'),
|
||||
);
|
||||
];
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler->expects($this->never())
|
||||
@@ -63,7 +63,7 @@ class MailHandlerTest extends TestCase
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
|
||||
$record = $this->getRecord();
|
||||
$records = array($record);
|
||||
$records = [$record];
|
||||
$records[0]['formatted'] = '['.$record['datetime'].'] test.WARNING: test [] []'."\n";
|
||||
|
||||
$handler->expects($this->once())
|
||||
|
@@ -24,7 +24,7 @@ class NativeMailerHandlerTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
$GLOBALS['mail'] = array();
|
||||
$GLOBALS['mail'] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ class NativeMailerHandlerTest extends TestCase
|
||||
public function testSetterArrayHeaderInjection()
|
||||
{
|
||||
$mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org');
|
||||
$mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org"));
|
||||
$mailer->addHeader(["Content-Type: text/html\r\nFrom: faked@attacker.org"]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class NativeMailerHandlerTest extends TestCase
|
||||
$from = 'receiver@example.org';
|
||||
|
||||
$mailer = new NativeMailerHandler($to, $subject, $from);
|
||||
$mailer->handleBatch(array());
|
||||
$mailer->handleBatch([]);
|
||||
|
||||
// batch is empty, nothing sent
|
||||
$this->assertEmpty($GLOBALS['mail']);
|
||||
|
@@ -24,7 +24,7 @@ class NewRelicHandlerTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
self::$appname = null;
|
||||
self::$customParameters = array();
|
||||
self::$customParameters = [];
|
||||
self::$transactionName = null;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ class NewRelicHandlerTest extends TestCase
|
||||
public function testThehandlerCanAddContextParamsToTheNewRelicTrace()
|
||||
{
|
||||
$handler = new StubNewRelicHandler();
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')));
|
||||
$this->assertEquals(array('context_a' => 'b'), self::$customParameters);
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', ['a' => 'b']));
|
||||
$this->assertEquals(['context_a' => 'b'], self::$customParameters);
|
||||
}
|
||||
|
||||
public function testThehandlerCanAddExplodedContextParamsToTheNewRelicTrace()
|
||||
@@ -56,10 +56,10 @@ class NewRelicHandlerTest extends TestCase
|
||||
$handler->handle($this->getRecord(
|
||||
Logger::ERROR,
|
||||
'log message',
|
||||
array('a' => array('key1' => 'value1', 'key2' => 'value2'))
|
||||
['a' => ['key1' => 'value1', 'key2' => 'value2']]
|
||||
));
|
||||
$this->assertEquals(
|
||||
array('context_a_key1' => 'value1', 'context_a_key2' => 'value2'),
|
||||
['context_a_key1' => 'value1', 'context_a_key2' => 'value2'],
|
||||
self::$customParameters
|
||||
);
|
||||
}
|
||||
@@ -67,40 +67,40 @@ class NewRelicHandlerTest extends TestCase
|
||||
public function testThehandlerCanAddExtraParamsToTheNewRelicTrace()
|
||||
{
|
||||
$record = $this->getRecord(Logger::ERROR, 'log message');
|
||||
$record['extra'] = array('c' => 'd');
|
||||
$record['extra'] = ['c' => 'd'];
|
||||
|
||||
$handler = new StubNewRelicHandler();
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertEquals(array('extra_c' => 'd'), self::$customParameters);
|
||||
$this->assertEquals(['extra_c' => 'd'], self::$customParameters);
|
||||
}
|
||||
|
||||
public function testThehandlerCanAddExplodedExtraParamsToTheNewRelicTrace()
|
||||
{
|
||||
$record = $this->getRecord(Logger::ERROR, 'log message');
|
||||
$record['extra'] = array('c' => array('key1' => 'value1', 'key2' => 'value2'));
|
||||
$record['extra'] = ['c' => ['key1' => 'value1', 'key2' => 'value2']];
|
||||
|
||||
$handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true);
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertEquals(
|
||||
array('extra_c_key1' => 'value1', 'extra_c_key2' => 'value2'),
|
||||
['extra_c_key1' => 'value1', 'extra_c_key2' => 'value2'],
|
||||
self::$customParameters
|
||||
);
|
||||
}
|
||||
|
||||
public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace()
|
||||
{
|
||||
$record = $this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'));
|
||||
$record['extra'] = array('c' => 'd');
|
||||
$record = $this->getRecord(Logger::ERROR, 'log message', ['a' => 'b']);
|
||||
$record['extra'] = ['c' => 'd'];
|
||||
|
||||
$handler = new StubNewRelicHandler();
|
||||
$handler->handle($record);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'context_a' => 'b',
|
||||
'extra_c' => 'd',
|
||||
);
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, self::$customParameters);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ class NewRelicHandlerTest extends TestCase
|
||||
public function testTheAppNameCanBeOverriddenFromEachLog()
|
||||
{
|
||||
$handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName');
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName')));
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', ['appname' => 'logAppName']));
|
||||
|
||||
$this->assertEquals('logAppName', self::$appname);
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class NewRelicHandlerTest extends TestCase
|
||||
public function testTheTransactionNameCanBeOverriddenFromEachLog()
|
||||
{
|
||||
$handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction');
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', array('transaction_name' => 'logTransactName')));
|
||||
$handler->handle($this->getRecord(Logger::ERROR, 'log message', ['transaction_name' => 'logTransactName']));
|
||||
|
||||
$this->assertEquals('logTransactName', self::$transactionName);
|
||||
}
|
||||
|
@@ -52,8 +52,8 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
{
|
||||
return $this->getMockBuilder('PhpConsole\Dispatcher\Debug')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('dispatchDebug'))
|
||||
->setConstructorArgs(array($connector, $connector->getDumper()))
|
||||
->setMethods(['dispatchDebug'])
|
||||
->setConstructorArgs([$connector, $connector->getDumper()])
|
||||
->getMock();
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
{
|
||||
return $this->getMockBuilder('PhpConsole\Dispatcher\Errors')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('dispatchError', 'dispatchException'))
|
||||
->setConstructorArgs(array($connector, $connector->getDumper()))
|
||||
->setMethods(['dispatchError', 'dispatchException'])
|
||||
->setConstructorArgs([$connector, $connector->getDumper()])
|
||||
->getMock();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
{
|
||||
$connector = $this->getMockBuilder('PhpConsole\Connector')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array(
|
||||
->setMethods([
|
||||
'sendMessage',
|
||||
'onShutDown',
|
||||
'isActiveClient',
|
||||
@@ -81,7 +81,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
'setAllowedIpMasks',
|
||||
'setHeadersLimit',
|
||||
'startEvalRequestsListener',
|
||||
))
|
||||
])
|
||||
->getMock();
|
||||
|
||||
$connector->expects($this->any())
|
||||
@@ -93,17 +93,17 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
|
||||
protected function getHandlerDefaultOption($name)
|
||||
{
|
||||
$handler = new PHPConsoleHandler(array(), $this->connector);
|
||||
$handler = new PHPConsoleHandler([], $this->connector);
|
||||
$options = $handler->getOptions();
|
||||
|
||||
return $options[$name];
|
||||
}
|
||||
|
||||
protected function initLogger($handlerOptions = array(), $level = Logger::DEBUG)
|
||||
protected function initLogger($handlerOptions = [], $level = Logger::DEBUG)
|
||||
{
|
||||
return new Logger('test', array(
|
||||
return new Logger('test', [
|
||||
new PHPConsoleHandler($handlerOptions, $this->connector, $level),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
public function testInitWithDefaultConnector()
|
||||
@@ -114,7 +114,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
|
||||
public function testInitWithCustomConnector()
|
||||
{
|
||||
$handler = new PHPConsoleHandler(array(), $this->connector);
|
||||
$handler = new PHPConsoleHandler([], $this->connector);
|
||||
$this->assertEquals(spl_object_hash($this->connector), spl_object_hash($handler->getConnector()));
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
{
|
||||
$message = 'test';
|
||||
$tag = 'tag';
|
||||
$context = array($tag, 'custom' => mt_rand());
|
||||
$context = [$tag, 'custom' => mt_rand()];
|
||||
$expectedMessage = $message . ' ' . json_encode(array_slice($context, 1));
|
||||
$this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with(
|
||||
$this->equalTo($expectedMessage),
|
||||
@@ -140,7 +140,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
public function testDebugTags($tagsContextKeys = null)
|
||||
{
|
||||
$expectedTags = mt_rand();
|
||||
$logger = $this->initLogger($tagsContextKeys ? array('debugTagsKeysInContext' => $tagsContextKeys) : array());
|
||||
$logger = $this->initLogger($tagsContextKeys ? ['debugTagsKeysInContext' => $tagsContextKeys] : []);
|
||||
if (!$tagsContextKeys) {
|
||||
$tagsContextKeys = $this->getHandlerDefaultOption('debugTagsKeysInContext');
|
||||
}
|
||||
@@ -151,7 +151,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
$this->equalTo($expectedTags)
|
||||
);
|
||||
$this->connector->setDebugDispatcher($debugDispatcher);
|
||||
$logger->debug('test', array($key => $expectedTags));
|
||||
$logger->debug('test', [$key => $expectedTags]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
$this->equalTo($line),
|
||||
$classesPartialsTraceIgnore ?: $this->equalTo($this->getHandlerDefaultOption('classesPartialsTraceIgnore'))
|
||||
);
|
||||
$errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? array('classesPartialsTraceIgnore' => $classesPartialsTraceIgnore) : array()), false);
|
||||
$errorHandler->registerErrorHandler(array(), false, E_USER_WARNING);
|
||||
$errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? ['classesPartialsTraceIgnore' => $classesPartialsTraceIgnore] : []), false);
|
||||
$errorHandler->registerErrorHandler([], false, E_USER_WARNING);
|
||||
$errorHandler->handleError($code, $message, $file, $line);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
$handler->log(
|
||||
\Psr\Log\LogLevel::ERROR,
|
||||
sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
|
||||
array('exception' => $e)
|
||||
['exception' => $e]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,45 +192,45 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWrongOptionsThrowsException()
|
||||
{
|
||||
new PHPConsoleHandler(array('xxx' => 1));
|
||||
new PHPConsoleHandler(['xxx' => 1]);
|
||||
}
|
||||
|
||||
public function testOptionEnabled()
|
||||
{
|
||||
$this->debugDispatcher->expects($this->never())->method('dispatchDebug');
|
||||
$this->initLogger(array('enabled' => false))->debug('test');
|
||||
$this->initLogger(['enabled' => false])->debug('test');
|
||||
}
|
||||
|
||||
public function testOptionClassesPartialsTraceIgnore()
|
||||
{
|
||||
$this->testError(array('Class', 'Namespace\\'));
|
||||
$this->testError(['Class', 'Namespace\\']);
|
||||
}
|
||||
|
||||
public function testOptionDebugTagsKeysInContext()
|
||||
{
|
||||
$this->testDebugTags(array('key1', 'key2'));
|
||||
$this->testDebugTags(['key1', 'key2']);
|
||||
}
|
||||
|
||||
public function testOptionUseOwnErrorsAndExceptionsHandler()
|
||||
{
|
||||
$this->initLogger(array('useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true));
|
||||
$this->assertEquals(array(VendorPhpConsoleHandler::getInstance(), 'handleError'), set_error_handler(function () {
|
||||
$this->initLogger(['useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true]);
|
||||
$this->assertEquals([VendorPhpConsoleHandler::getInstance(), 'handleError'], set_error_handler(function () {
|
||||
}));
|
||||
$this->assertEquals(array(VendorPhpConsoleHandler::getInstance(), 'handleException'), set_exception_handler(function () {
|
||||
$this->assertEquals([VendorPhpConsoleHandler::getInstance(), 'handleException'], set_exception_handler(function () {
|
||||
}));
|
||||
}
|
||||
|
||||
public static function provideConnectorMethodsOptionsSets()
|
||||
{
|
||||
return array(
|
||||
array('sourcesBasePath', 'setSourcesBasePath', __DIR__),
|
||||
array('serverEncoding', 'setServerEncoding', 'cp1251'),
|
||||
array('password', 'setPassword', '******'),
|
||||
array('enableSslOnlyMode', 'enableSslOnlyMode', true, false),
|
||||
array('ipMasks', 'setAllowedIpMasks', array('127.0.0.*')),
|
||||
array('headersLimit', 'setHeadersLimit', 2500),
|
||||
array('enableEvalListener', 'startEvalRequestsListener', true, false),
|
||||
);
|
||||
return [
|
||||
['sourcesBasePath', 'setSourcesBasePath', __DIR__],
|
||||
['serverEncoding', 'setServerEncoding', 'cp1251'],
|
||||
['password', 'setPassword', '******'],
|
||||
['enableSslOnlyMode', 'enableSslOnlyMode', true, false],
|
||||
['ipMasks', 'setAllowedIpMasks', ['127.0.0.*']],
|
||||
['headersLimit', 'setHeadersLimit', 2500],
|
||||
['enableEvalListener', 'startEvalRequestsListener', true, false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,24 +242,24 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
if ($isArgument) {
|
||||
$expectCall->with($value);
|
||||
}
|
||||
new PHPConsoleHandler(array($option => $value), $this->connector);
|
||||
new PHPConsoleHandler([$option => $value], $this->connector);
|
||||
}
|
||||
|
||||
public function testOptionDetectDumpTraceAndSource()
|
||||
{
|
||||
new PHPConsoleHandler(array('detectDumpTraceAndSource' => true), $this->connector);
|
||||
new PHPConsoleHandler(['detectDumpTraceAndSource' => true], $this->connector);
|
||||
$this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource);
|
||||
}
|
||||
|
||||
public static function provideDumperOptionsValues()
|
||||
{
|
||||
return array(
|
||||
array('dumperLevelLimit', 'levelLimit', 1001),
|
||||
array('dumperItemsCountLimit', 'itemsCountLimit', 1002),
|
||||
array('dumperItemSizeLimit', 'itemSizeLimit', 1003),
|
||||
array('dumperDumpSizeLimit', 'dumpSizeLimit', 1004),
|
||||
array('dumperDetectCallbacks', 'detectCallbacks', true),
|
||||
);
|
||||
return [
|
||||
['dumperLevelLimit', 'levelLimit', 1001],
|
||||
['dumperItemsCountLimit', 'itemsCountLimit', 1002],
|
||||
['dumperItemSizeLimit', 'itemSizeLimit', 1003],
|
||||
['dumperDumpSizeLimit', 'dumpSizeLimit', 1004],
|
||||
['dumperDetectCallbacks', 'detectCallbacks', true],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +267,7 @@ class PHPConsoleHandlerTest extends TestCase
|
||||
*/
|
||||
public function testDumperOptions($option, $dumperProperty, $value)
|
||||
{
|
||||
new PHPConsoleHandler(array($option => $value), $this->connector);
|
||||
new PHPConsoleHandler([$option => $value], $this->connector);
|
||||
$this->assertEquals($value, $this->connector->getDumper()->$dumperProperty);
|
||||
}
|
||||
}
|
||||
|
@@ -34,15 +34,15 @@ class ProcessHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteOpensProcessAndWritesToStdInOfProcess()
|
||||
{
|
||||
$fixtures = array(
|
||||
$fixtures = [
|
||||
'chuck norris',
|
||||
'foobar1337'
|
||||
);
|
||||
'foobar1337',
|
||||
];
|
||||
|
||||
$mockBuilder = $this->getMockBuilder('Monolog\Handler\ProcessHandler');
|
||||
$mockBuilder->setMethods(array('writeProcessInput'));
|
||||
$mockBuilder->setMethods(['writeProcessInput']);
|
||||
// using echo as command, as it is most probably available
|
||||
$mockBuilder->setConstructorArgs(array(self::DUMMY_COMMAND));
|
||||
$mockBuilder->setConstructorArgs([self::DUMMY_COMMAND]);
|
||||
|
||||
$handler = $mockBuilder->getMock();
|
||||
|
||||
@@ -126,8 +126,8 @@ class ProcessHandlerTest extends TestCase
|
||||
public function testStartupWithFailingToSelectErrorStreamThrowsUnexpectedValueException()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder('Monolog\Handler\ProcessHandler');
|
||||
$mockBuilder->setMethods(array('selectErrorStream'));
|
||||
$mockBuilder->setConstructorArgs(array(self::DUMMY_COMMAND));
|
||||
$mockBuilder->setMethods(['selectErrorStream']);
|
||||
$mockBuilder->setConstructorArgs([self::DUMMY_COMMAND]);
|
||||
|
||||
$handler = $mockBuilder->getMock();
|
||||
|
||||
@@ -157,9 +157,9 @@ class ProcessHandlerTest extends TestCase
|
||||
public function testWritingWithErrorsOnStdOutOfProcessThrowsInvalidArgumentException()
|
||||
{
|
||||
$mockBuilder = $this->getMockBuilder('Monolog\Handler\ProcessHandler');
|
||||
$mockBuilder->setMethods(array('readProcessErrors'));
|
||||
$mockBuilder->setMethods(['readProcessErrors']);
|
||||
// using echo as command, as it is most probably available
|
||||
$mockBuilder->setConstructorArgs(array(self::DUMMY_COMMAND));
|
||||
$mockBuilder->setConstructorArgs([self::DUMMY_COMMAND]);
|
||||
|
||||
$handler = $mockBuilder->getMock();
|
||||
|
||||
|
@@ -21,11 +21,11 @@ class PsrHandlerTest extends TestCase
|
||||
{
|
||||
public function logLevelProvider()
|
||||
{
|
||||
$levels = array();
|
||||
$levels = [];
|
||||
$monologLogger = new Logger('');
|
||||
|
||||
foreach ($monologLogger->getLevels() as $levelName => $level) {
|
||||
$levels[] = array($levelName, $level);
|
||||
$levels[] = [$levelName, $level];
|
||||
}
|
||||
|
||||
return $levels;
|
||||
@@ -37,7 +37,7 @@ class PsrHandlerTest extends TestCase
|
||||
public function testHandlesAllLevels($levelName, $level)
|
||||
{
|
||||
$message = 'Hello, world! ' . $level;
|
||||
$context = array('foo' => 'bar', 'level' => $level);
|
||||
$context = ['foo' => 'bar', 'level' => $level];
|
||||
|
||||
$psrLogger = $this->getMock('Psr\Log\NullLogger');
|
||||
$psrLogger->expects($this->once())
|
||||
@@ -45,6 +45,6 @@ class PsrHandlerTest extends TestCase
|
||||
->with(strtolower($levelName), $message, $context);
|
||||
|
||||
$handler = new PsrHandler($psrLogger);
|
||||
$handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context));
|
||||
$handler->handle(['level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context]);
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ class PushoverHandlerTest extends TestCase
|
||||
|
||||
public function testWriteToMultipleUsers()
|
||||
{
|
||||
$this->createHandler('myToken', array('userA', 'userB'));
|
||||
$this->createHandler('myToken', ['userA', 'userB']);
|
||||
$this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
@@ -114,11 +114,11 @@ class PushoverHandlerTest extends TestCase
|
||||
|
||||
private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
|
||||
{
|
||||
$constructorArgs = array($token, $user, $title);
|
||||
$constructorArgs = [$token, $user, $title];
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\PushoverHandler',
|
||||
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
||||
['fsockopen', 'streamSetTimeout', 'closeSocket'],
|
||||
$constructorArgs
|
||||
);
|
||||
|
||||
|
@@ -78,8 +78,8 @@ class RavenHandlerTest extends TestCase
|
||||
$ravenClient = $this->getRavenClient();
|
||||
$handler = $this->getHandler($ravenClient);
|
||||
|
||||
$tags = array(1, 2, 'foo');
|
||||
$record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags));
|
||||
$tags = [1, 2, 'foo'];
|
||||
$record = $this->getRecord(Logger::INFO, 'test', ['tags' => $tags]);
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertEquals($tags, $ravenClient->lastData['tags']);
|
||||
@@ -92,7 +92,7 @@ class RavenHandlerTest extends TestCase
|
||||
|
||||
$checksum = '098f6bcd4621d373cade4e832627b4f6';
|
||||
$release = '05a671c66aefea124cc08b76ea6d30bb';
|
||||
$record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum, 'release' => $release));
|
||||
$record = $this->getRecord(Logger::INFO, 'test', ['checksum' => $checksum, 'release' => $release]);
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertEquals($checksum, $ravenClient->lastData['checksum']);
|
||||
@@ -104,8 +104,8 @@ class RavenHandlerTest extends TestCase
|
||||
$ravenClient = $this->getRavenClient();
|
||||
$handler = $this->getHandler($ravenClient);
|
||||
|
||||
$fingerprint = array('{{ default }}', 'other value');
|
||||
$record = $this->getRecord(Logger::INFO, 'test', array('fingerprint' => $fingerprint));
|
||||
$fingerprint = ['{{ default }}', 'other value'];
|
||||
$record = $this->getRecord(Logger::INFO, 'test', ['fingerprint' => $fingerprint]);
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertEquals($fingerprint, $ravenClient->lastData['fingerprint']);
|
||||
@@ -119,14 +119,14 @@ class RavenHandlerTest extends TestCase
|
||||
$recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
|
||||
// set user context 'externally'
|
||||
|
||||
$user = array(
|
||||
$user = [
|
||||
'id' => '123',
|
||||
'email' => 'test@test.com',
|
||||
);
|
||||
];
|
||||
|
||||
$recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
|
||||
$recordWithContext = $this->getRecord(Logger::INFO, 'test', ['user' => $user]);
|
||||
|
||||
$ravenClient->user_context(array('id' => 'test_user_id'));
|
||||
$ravenClient->user_context(['id' => 'test_user_id']);
|
||||
// handle context
|
||||
$handler->handle($recordWithContext);
|
||||
$this->assertEquals($user, $ravenClient->lastData['user']);
|
||||
@@ -154,7 +154,7 @@ class RavenHandlerTest extends TestCase
|
||||
try {
|
||||
$this->methodThatThrowsAnException();
|
||||
} catch (\Exception $e) {
|
||||
$record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
|
||||
$record = $this->getRecord(Logger::ERROR, $e->getMessage(), ['exception' => $e]);
|
||||
$handler->handle($record);
|
||||
}
|
||||
|
||||
@@ -183,13 +183,13 @@ class RavenHandlerTest extends TestCase
|
||||
|
||||
public function testHandleBatchDoNothingIfRecordsAreBelowLevel()
|
||||
{
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
||||
$this->getRecord(Logger::INFO, 'information'),
|
||||
);
|
||||
];
|
||||
|
||||
$handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
|
||||
$handler = $this->getMock('Monolog\Handler\RavenHandler', null, [$this->getRavenClient()]);
|
||||
$handler->expects($this->never())->method('handle');
|
||||
$handler->setLevel(Logger::ERROR);
|
||||
$handler->handleBatch($records);
|
||||
@@ -215,7 +215,7 @@ class RavenHandlerTest extends TestCase
|
||||
$this->assertEquals($release, $ravenClient->lastData['release']);
|
||||
|
||||
$localRelease = 'v41.41.41';
|
||||
$record = $this->getRecord(Logger::INFO, 'test', array('release' => $localRelease));
|
||||
$record = $this->getRecord(Logger::INFO, 'test', ['release' => $localRelease]);
|
||||
$handler->handle($record);
|
||||
$this->assertEquals($localRelease, $ravenClient->lastData['release']);
|
||||
}
|
||||
|
@@ -39,14 +39,14 @@ class RedisHandlerTest extends TestCase
|
||||
|
||||
public function testPredisHandle()
|
||||
{
|
||||
$redis = $this->getMock('Predis\Client', array('rpush'));
|
||||
$redis = $this->getMock('Predis\Client', ['rpush']);
|
||||
|
||||
// Predis\Client uses rpush
|
||||
$redis->expects($this->once())
|
||||
->method('rpush')
|
||||
->with('key', 'test');
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new RedisHandler($redis, 'key');
|
||||
$handler->setFormatter(new LineFormatter("%message%"));
|
||||
@@ -55,14 +55,14 @@ class RedisHandlerTest extends TestCase
|
||||
|
||||
public function testRedisHandle()
|
||||
{
|
||||
$redis = $this->getMock('Redis', array('rpush'));
|
||||
$redis = $this->getMock('Redis', ['rpush']);
|
||||
|
||||
// Redis uses rPush
|
||||
$redis->expects($this->once())
|
||||
->method('rPush')
|
||||
->with('key', 'test');
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new RedisHandler($redis, 'key');
|
||||
$handler->setFormatter(new LineFormatter("%message%"));
|
||||
@@ -71,7 +71,7 @@ class RedisHandlerTest extends TestCase
|
||||
|
||||
public function testRedisHandleCapped()
|
||||
{
|
||||
$redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'exec'));
|
||||
$redis = $this->getMock('Redis', ['multi', 'rpush', 'ltrim', 'exec']);
|
||||
|
||||
// Redis uses multi
|
||||
$redis->expects($this->once())
|
||||
@@ -90,7 +90,7 @@ class RedisHandlerTest extends TestCase
|
||||
->method('exec')
|
||||
->will($this->returnSelf());
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
|
||||
$handler->setFormatter(new LineFormatter("%message%"));
|
||||
@@ -99,9 +99,9 @@ class RedisHandlerTest extends TestCase
|
||||
|
||||
public function testPredisHandleCapped()
|
||||
{
|
||||
$redis = $this->getMock('Predis\Client', array('transaction'));
|
||||
$redis = $this->getMock('Predis\Client', ['transaction']);
|
||||
|
||||
$redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim'));
|
||||
$redisTransaction = $this->getMock('Predis\Client', ['rpush', 'ltrim']);
|
||||
|
||||
$redisTransaction->expects($this->once())
|
||||
->method('rpush')
|
||||
@@ -118,7 +118,7 @@ class RedisHandlerTest extends TestCase
|
||||
$cb($redisTransaction);
|
||||
}));
|
||||
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);
|
||||
|
||||
$handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
|
||||
$handler->setFormatter(new LineFormatter("%message%"));
|
||||
|
@@ -13,7 +13,6 @@ namespace Monolog\Handler;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Monolog\Test\TestCase;
|
||||
use PHPUnit_Framework_Error_Deprecated;
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\RotatingFileHandler
|
||||
@@ -38,11 +37,11 @@ class RotatingFileHandlerTest extends TestCase
|
||||
$this->lastError = null;
|
||||
$self = $this;
|
||||
// workaround with &$self used for PHP 5.3
|
||||
set_error_handler(function($code, $message) use (&$self) {
|
||||
$self->lastError = array(
|
||||
set_error_handler(function ($code, $message) use (&$self) {
|
||||
$self->lastError = [
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
);
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -108,32 +107,32 @@ class RotatingFileHandlerTest extends TestCase
|
||||
public function rotationTests()
|
||||
{
|
||||
$now = time();
|
||||
$dayCallback = function($ago) use ($now) {
|
||||
$dayCallback = function ($ago) use ($now) {
|
||||
return $now + 86400 * $ago;
|
||||
};
|
||||
$monthCallback = function($ago) {
|
||||
$monthCallback = function ($ago) {
|
||||
return gmmktime(0, 0, 0, date('n') + $ago, date('d'), date('Y'));
|
||||
};
|
||||
$yearCallback = function($ago) {
|
||||
$yearCallback = function ($ago) {
|
||||
return gmmktime(0, 0, 0, date('n'), date('d'), date('Y') + $ago);
|
||||
};
|
||||
|
||||
return array(
|
||||
return [
|
||||
'Rotation is triggered when the file of the current day is not present'
|
||||
=> array(true, RotatingFileHandler::FILE_PER_DAY, $dayCallback),
|
||||
=> [true, RotatingFileHandler::FILE_PER_DAY, $dayCallback],
|
||||
'Rotation is not triggered when the file of the current day is already present'
|
||||
=> array(false, RotatingFileHandler::FILE_PER_DAY, $dayCallback),
|
||||
=> [false, RotatingFileHandler::FILE_PER_DAY, $dayCallback],
|
||||
|
||||
'Rotation is triggered when the file of the current month is not present'
|
||||
=> array(true, RotatingFileHandler::FILE_PER_MONTH, $monthCallback),
|
||||
=> [true, RotatingFileHandler::FILE_PER_MONTH, $monthCallback],
|
||||
'Rotation is not triggered when the file of the current month is already present'
|
||||
=> array(false, RotatingFileHandler::FILE_PER_MONTH, $monthCallback),
|
||||
=> [false, RotatingFileHandler::FILE_PER_MONTH, $monthCallback],
|
||||
|
||||
'Rotation is triggered when the file of the current year is not present'
|
||||
=> array(true, RotatingFileHandler::FILE_PER_YEAR, $yearCallback),
|
||||
=> [true, RotatingFileHandler::FILE_PER_YEAR, $yearCallback],
|
||||
'Rotation is not triggered when the file of the current year is already present'
|
||||
=> array(false, RotatingFileHandler::FILE_PER_YEAR, $yearCallback),
|
||||
);
|
||||
=> [false, RotatingFileHandler::FILE_PER_YEAR, $yearCallback],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,13 +149,13 @@ class RotatingFileHandlerTest extends TestCase
|
||||
|
||||
public function dateFormatProvider()
|
||||
{
|
||||
return array(
|
||||
array(RotatingFileHandler::FILE_PER_DAY, true),
|
||||
array(RotatingFileHandler::FILE_PER_MONTH, true),
|
||||
array(RotatingFileHandler::FILE_PER_YEAR, true),
|
||||
array('m-d-Y', false),
|
||||
array('Y-m-d-h-i', false)
|
||||
);
|
||||
return [
|
||||
[RotatingFileHandler::FILE_PER_DAY, true],
|
||||
[RotatingFileHandler::FILE_PER_MONTH, true],
|
||||
[RotatingFileHandler::FILE_PER_YEAR, true],
|
||||
['m-d-Y', false],
|
||||
['Y-m-d-h-i', false],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,15 +173,15 @@ class RotatingFileHandlerTest extends TestCase
|
||||
|
||||
public function filenameFormatProvider()
|
||||
{
|
||||
return array(
|
||||
array('{filename}', false),
|
||||
array('{filename}-{date}', true),
|
||||
array('{date}', true),
|
||||
array('foobar-{date}', true),
|
||||
array('foo-{date}-bar', true),
|
||||
array('{date}-foobar', true),
|
||||
array('foobar', false),
|
||||
);
|
||||
return [
|
||||
['{filename}', false],
|
||||
['{filename}-{date}', true],
|
||||
['{date}', true],
|
||||
['foobar-{date}', true],
|
||||
['foo-{date}-bar', true],
|
||||
['{date}-foobar', true],
|
||||
['foobar', false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testReuseCurrentFile()
|
||||
|
@@ -92,25 +92,25 @@ class SlackHandlerTest extends TestCase
|
||||
|
||||
public function provideLevelColors()
|
||||
{
|
||||
return array(
|
||||
array(Logger::DEBUG, '%23e3e4e6'), // escaped #e3e4e6
|
||||
array(Logger::INFO, 'good'),
|
||||
array(Logger::NOTICE, 'good'),
|
||||
array(Logger::WARNING, 'warning'),
|
||||
array(Logger::ERROR, 'danger'),
|
||||
array(Logger::CRITICAL, 'danger'),
|
||||
array(Logger::ALERT, 'danger'),
|
||||
array(Logger::EMERGENCY,'danger'),
|
||||
);
|
||||
return [
|
||||
[Logger::DEBUG, '%23e3e4e6'], // escaped #e3e4e6
|
||||
[Logger::INFO, 'good'],
|
||||
[Logger::NOTICE, 'good'],
|
||||
[Logger::WARNING, 'warning'],
|
||||
[Logger::ERROR, 'danger'],
|
||||
[Logger::CRITICAL, 'danger'],
|
||||
[Logger::ALERT, 'danger'],
|
||||
[Logger::EMERGENCY,'danger'],
|
||||
];
|
||||
}
|
||||
|
||||
private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeExtra = false)
|
||||
{
|
||||
$constructorArgs = array($token, $channel, $username, $useAttachment, $iconEmoji, Logger::DEBUG, true, $useShortAttachment, $includeExtra);
|
||||
$constructorArgs = [$token, $channel, $username, $useAttachment, $iconEmoji, Logger::DEBUG, true, $useShortAttachment, $includeExtra];
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\SlackHandler',
|
||||
array('fsockopen', 'streamSetTimeout', 'closeSocket'),
|
||||
['fsockopen', 'streamSetTimeout', 'closeSocket'],
|
||||
$constructorArgs
|
||||
);
|
||||
|
||||
|
@@ -88,7 +88,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testExceptionIsThrownOnFsockopenError()
|
||||
{
|
||||
$this->setMockHandler(array('fsockopen'));
|
||||
$this->setMockHandler(['fsockopen']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('fsockopen')
|
||||
->will($this->returnValue(false));
|
||||
@@ -100,7 +100,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testExceptionIsThrownOnPfsockopenError()
|
||||
{
|
||||
$this->setMockHandler(array('pfsockopen'));
|
||||
$this->setMockHandler(['pfsockopen']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('pfsockopen')
|
||||
->will($this->returnValue(false));
|
||||
@@ -113,7 +113,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testExceptionIsThrownIfCannotSetTimeout()
|
||||
{
|
||||
$this->setMockHandler(array('streamSetTimeout'));
|
||||
$this->setMockHandler(['streamSetTimeout']);
|
||||
$this->handler->expects($this->once())
|
||||
->method('streamSetTimeout')
|
||||
->will($this->returnValue(false));
|
||||
@@ -125,13 +125,13 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteFailsOnIfFwriteReturnsFalse()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite'));
|
||||
$this->setMockHandler(['fwrite']);
|
||||
|
||||
$callback = function ($arg) {
|
||||
$map = array(
|
||||
$map = [
|
||||
'Hello world' => 6,
|
||||
'world' => false,
|
||||
);
|
||||
];
|
||||
|
||||
return $map[$arg];
|
||||
};
|
||||
@@ -148,13 +148,13 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteFailsIfStreamTimesOut()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
|
||||
|
||||
$callback = function ($arg) {
|
||||
$map = array(
|
||||
$map = [
|
||||
'Hello world' => 6,
|
||||
'world' => 5,
|
||||
);
|
||||
];
|
||||
|
||||
return $map[$arg];
|
||||
};
|
||||
@@ -164,7 +164,7 @@ class SocketHandlerTest extends TestCase
|
||||
->will($this->returnCallback($callback));
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(array('timed_out' => true)));
|
||||
->will($this->returnValue(['timed_out' => true]));
|
||||
|
||||
$this->writeRecord('Hello world');
|
||||
}
|
||||
@@ -174,7 +174,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testWriteFailsOnIncompleteWrite()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
|
||||
|
||||
$res = $this->res;
|
||||
$callback = function ($string) use ($res) {
|
||||
@@ -188,7 +188,7 @@ class SocketHandlerTest extends TestCase
|
||||
->will($this->returnCallback($callback));
|
||||
$this->handler->expects($this->exactly(1))
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(array('timed_out' => false)));
|
||||
->will($this->returnValue(['timed_out' => false]));
|
||||
|
||||
$this->writeRecord('Hello world');
|
||||
}
|
||||
@@ -205,13 +205,13 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
public function testWriteWithMock()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite'));
|
||||
$this->setMockHandler(['fwrite']);
|
||||
|
||||
$callback = function ($arg) {
|
||||
$map = array(
|
||||
$map = [
|
||||
'Hello world' => 6,
|
||||
'world' => 5,
|
||||
);
|
||||
];
|
||||
|
||||
return $map[$arg];
|
||||
};
|
||||
@@ -247,7 +247,7 @@ class SocketHandlerTest extends TestCase
|
||||
*/
|
||||
public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
|
||||
{
|
||||
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
|
||||
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('fwrite')
|
||||
@@ -255,7 +255,7 @@ class SocketHandlerTest extends TestCase
|
||||
|
||||
$this->handler->expects($this->any())
|
||||
->method('streamGetMetadata')
|
||||
->will($this->returnValue(array('timed_out' => false)));
|
||||
->will($this->returnValue(['timed_out' => false]));
|
||||
|
||||
$this->handler->setWritingTimeout(1);
|
||||
|
||||
@@ -273,17 +273,17 @@ class SocketHandlerTest extends TestCase
|
||||
$this->handler->handle($this->getRecord(Logger::WARNING, $string));
|
||||
}
|
||||
|
||||
private function setMockHandler(array $methods = array())
|
||||
private function setMockHandler(array $methods = [])
|
||||
{
|
||||
$this->res = fopen('php://memory', 'a');
|
||||
|
||||
$defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout');
|
||||
$defaultMethods = ['fsockopen', 'pfsockopen', 'streamSetTimeout'];
|
||||
$newMethods = array_diff($methods, $defaultMethods);
|
||||
|
||||
$finalMethods = array_merge($defaultMethods, $newMethods);
|
||||
|
||||
$this->handler = $this->getMock(
|
||||
'\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234')
|
||||
'\Monolog\Handler\SocketHandler', $finalMethods, ['localhost:1234']
|
||||
);
|
||||
|
||||
if (!in_array('fsockopen', $methods)) {
|
||||
|
@@ -93,11 +93,11 @@ class StreamHandlerTest extends TestCase
|
||||
|
||||
public function invalidArgumentProvider()
|
||||
{
|
||||
return array(
|
||||
array(1),
|
||||
array(array()),
|
||||
array(array('bogus://url')),
|
||||
);
|
||||
return [
|
||||
[1],
|
||||
[[]],
|
||||
[['bogus://url']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,10 +37,10 @@ class SwiftMailerHandlerTest extends TestCase
|
||||
};
|
||||
$handler = new SwiftMailerHandler($this->mailer, $callback);
|
||||
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(Logger::DEBUG),
|
||||
$this->getRecord(Logger::INFO),
|
||||
);
|
||||
];
|
||||
$handler->handleBatch($records);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ class SwiftMailerHandlerTest extends TestCase
|
||||
$handler = new SwiftMailerHandler($this->mailer, $callback);
|
||||
|
||||
// Logging 1 record makes this an Emergency
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(Logger::EMERGENCY),
|
||||
);
|
||||
];
|
||||
$handler->handleBatch($records);
|
||||
}
|
||||
|
||||
@@ -83,14 +83,15 @@ class SwiftMailerHandlerTest extends TestCase
|
||||
->method('send')
|
||||
->with($this->callback(function ($value) use (&$receivedMessage) {
|
||||
$receivedMessage = $value;
|
||||
|
||||
return true;
|
||||
}));
|
||||
|
||||
$handler = new SwiftMailerHandler($this->mailer, $messageTemplate);
|
||||
|
||||
$records = array(
|
||||
$records = [
|
||||
$this->getRecord(Logger::EMERGENCY),
|
||||
);
|
||||
];
|
||||
$handler->handleBatch($records);
|
||||
|
||||
$this->assertEquals('Alert: EMERGENCY test', $receivedMessage->getSubject());
|
||||
@@ -103,10 +104,10 @@ class SwiftMailerHandlerTest extends TestCase
|
||||
|
||||
$method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage');
|
||||
$method->setAccessible(true);
|
||||
$method->invokeArgs($handler, array($messageTemplate, array()));
|
||||
$method->invokeArgs($handler, [$messageTemplate, []]);
|
||||
|
||||
$builtMessage1 = $method->invoke($handler, $messageTemplate, array());
|
||||
$builtMessage2 = $method->invoke($handler, $messageTemplate, array());
|
||||
$builtMessage1 = $method->invoke($handler, $messageTemplate, []);
|
||||
$builtMessage2 = $method->invoke($handler, $messageTemplate, []);
|
||||
|
||||
$this->assertFalse($builtMessage1->getId() === $builtMessage2->getId(), 'Two different messages have the same id');
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
$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 = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', ['write'], ['lol', 'lol']);
|
||||
$socket->expects($this->at(0))
|
||||
->method('write')
|
||||
->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 ");
|
||||
@@ -44,6 +44,6 @@ class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function getRecordWithMessage($msg)
|
||||
{
|
||||
return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol');
|
||||
return ['message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => [], 'channel' => 'lol'];
|
||||
}
|
||||
}
|
||||
|
@@ -47,20 +47,20 @@ class TestHandlerTest extends TestCase
|
||||
|
||||
$records = $handler->getRecords();
|
||||
unset($records[0]['formatted']);
|
||||
$this->assertEquals(array($record), $records);
|
||||
$this->assertEquals([$record], $records);
|
||||
}
|
||||
|
||||
public function methodProvider()
|
||||
{
|
||||
return array(
|
||||
array('Emergency', Logger::EMERGENCY),
|
||||
array('Alert' , Logger::ALERT),
|
||||
array('Critical' , Logger::CRITICAL),
|
||||
array('Error' , Logger::ERROR),
|
||||
array('Warning' , Logger::WARNING),
|
||||
array('Info' , Logger::INFO),
|
||||
array('Notice' , Logger::NOTICE),
|
||||
array('Debug' , Logger::DEBUG),
|
||||
);
|
||||
return [
|
||||
['Emergency', Logger::EMERGENCY],
|
||||
['Alert' , Logger::ALERT],
|
||||
['Critical' , Logger::CRITICAL],
|
||||
['Error' , Logger::ERROR],
|
||||
['Warning' , Logger::WARNING],
|
||||
['Info' , Logger::INFO],
|
||||
['Notice' , Logger::NOTICE],
|
||||
['Debug' , Logger::DEBUG],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ class UdpSocketTest extends TestCase
|
||||
{
|
||||
public function testWeDoNotTruncateShortMessages()
|
||||
{
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', ['send'], ['lol', 'lol']);
|
||||
|
||||
$socket->expects($this->at(0))
|
||||
->method('send')
|
||||
@@ -32,7 +32,7 @@ class UdpSocketTest extends TestCase
|
||||
|
||||
public function testLongMessagesAreTruncated()
|
||||
{
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol'));
|
||||
$socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', ['send'], ['lol', 'lol']);
|
||||
|
||||
$truncatedString = str_repeat("derp", 16254).'d';
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testConstructorOnlyTakesHandler()
|
||||
{
|
||||
new WhatFailureGroupHandler(array(new TestHandler(), "foo"));
|
||||
new WhatFailureGroupHandler([new TestHandler(), "foo"]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandle()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(), new TestHandler());
|
||||
$testHandlers = [new TestHandler(), new TestHandler()];
|
||||
$handler = new WhatFailureGroupHandler($testHandlers);
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::INFO));
|
||||
@@ -47,9 +47,9 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testHandleBatch()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(), new TestHandler());
|
||||
$testHandlers = [new TestHandler(), new TestHandler()];
|
||||
$handler = new WhatFailureGroupHandler($testHandlers);
|
||||
$handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)));
|
||||
$handler->handleBatch([$this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO)]);
|
||||
foreach ($testHandlers as $test) {
|
||||
$this->assertTrue($test->hasDebugRecords());
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
@@ -62,7 +62,7 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
*/
|
||||
public function testIsHandling()
|
||||
{
|
||||
$testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING));
|
||||
$testHandlers = [new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)];
|
||||
$handler = new WhatFailureGroupHandler($testHandlers);
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR)));
|
||||
$this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING)));
|
||||
@@ -75,7 +75,7 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
public function testHandleUsesProcessors()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new WhatFailureGroupHandler(array($test));
|
||||
$handler = new WhatFailureGroupHandler([$test]);
|
||||
$handler->pushProcessor(function ($record) {
|
||||
$record['extra']['foo'] = true;
|
||||
|
||||
@@ -94,7 +94,7 @@ class WhatFailureGroupHandlerTest extends TestCase
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$exception = new ExceptionTestHandler();
|
||||
$handler = new WhatFailureGroupHandler(array($exception, $test, $exception));
|
||||
$handler = new WhatFailureGroupHandler([$exception, $test, $exception]);
|
||||
$handler->pushProcessor(function ($record) {
|
||||
$record['extra']['foo'] = true;
|
||||
|
||||
|
@@ -29,12 +29,12 @@ class ZendMonitorHandlerTest extends TestCase
|
||||
public function testWrite()
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
$formatterResult = array(
|
||||
$formatterResult = [
|
||||
'message' => $record['message'],
|
||||
);
|
||||
];
|
||||
|
||||
$zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
|
||||
->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
|
||||
->setMethods(['writeZendMonitorCustomEvent', 'getDefaultFormatter'])
|
||||
->getMock();
|
||||
|
||||
$formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
|
||||
|
Reference in New Issue
Block a user