1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-13 08:34:12 +02:00
This commit is contained in:
Jordi Boggiano
2014-03-23 20:50:26 +01:00
parent 8222de98a4
commit 392ef35fd4
29 changed files with 55 additions and 88 deletions

View File

@@ -70,7 +70,7 @@ class AbstractProcessingHandlerTest extends TestCase
$handledRecord = null;
$handler->expects($this->once())
->method('write')
->will($this->returnCallback(function($record) use (&$handledRecord) {
->will($this->returnCallback(function ($record) use (&$handledRecord) {
$handledRecord = $record;
}))
;

View File

@@ -40,7 +40,7 @@ class BrowserConsoleHandlerTest extends TestCase
$handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
(function (c) {if (c && c.groupCollapsed) {
c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
}})(console);
EOF;
@@ -56,7 +56,7 @@ EOF;
$handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
(function (c) {if (c && c.groupCollapsed) {
c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
}})(console);
EOF;
@@ -75,7 +75,7 @@ EOF;
$handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
(function (c) {if (c && c.groupCollapsed) {
c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
@@ -93,7 +93,7 @@ EOF;
$handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
(function (c) {if (c && c.groupCollapsed) {
c.groupCollapsed("%ctest", "font-weight: normal");
c.log("%c%s", "font-weight: bold", "Context");
c.log("%s: %o", "foo", "bar");
@@ -118,7 +118,7 @@ EOF;
$handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
$expected = <<<EOF
(function(c){if (c && c.groupCollapsed) {
(function (c) {if (c && c.groupCollapsed) {
c.log("%ctest1", "font-weight: normal");
c.log("%ctest2", "font-weight: normal");
c.log("%ctest3", "font-weight: normal");

View File

@@ -11,7 +11,6 @@
namespace Monolog\Handler;
use Monolog\Handler\ElasticSearchHandler;
use Monolog\Formatter\ElasticaFormatter;
use Monolog\Formatter\NormalizerFormatter;
use Monolog\TestCase;
@@ -185,7 +184,7 @@ class ElasticSearchHandlerTest extends TestCase
$handler = new ElasticSearchHandler($client, $this->options);
try {
$handler->handleBatch(array($msg));
} catch(\RuntimeException $e) {
} catch (\RuntimeException $e) {
$this->markTestSkipped("Cannot connect to Elastic Search server on localhost");
}
@@ -208,7 +207,7 @@ class ElasticSearchHandlerTest extends TestCase
/**
* Return last created document id from ES response
* @param Response $response Elastica Response object
* @param Response $response Elastica Response object
* @return string|null
*/
protected function getCreatedDocId(Response $response)
@@ -221,10 +220,10 @@ class ElasticSearchHandlerTest extends TestCase
/**
* Retrieve document by id from Elasticsearch
* @param Client $client Elastica client
* @param string $index
* @param string $type
* @param string $documentId
* @param Client $client Elastica client
* @param string $index
* @param string $type
* @param string $documentId
* @return array
*/
protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId)
@@ -234,6 +233,7 @@ class ElasticSearchHandlerTest extends TestCase
if (!empty($data['_source'])) {
return $data['_source'];
}
return array();
}
}

View File

@@ -102,7 +102,7 @@ class FingersCrossedHandlerTest extends TestCase
public function testHandleWithCallback()
{
$test = new TestHandler();
$handler = new FingersCrossedHandler(function($record, $handler) use ($test) {
$handler = new FingersCrossedHandler(function ($record, $handler) use ($test) {
return $test;
});
$handler->handle($this->getRecord(Logger::DEBUG));
@@ -120,7 +120,7 @@ class FingersCrossedHandlerTest extends TestCase
*/
public function testHandleWithBadCallbackThrowsException()
{
$handler = new FingersCrossedHandler(function($record, $handler) {
$handler = new FingersCrossedHandler(function ($record, $handler) {
return 'foo';
});
$handler->handle($this->getRecord(Logger::WARNING));

View File

@@ -23,8 +23,6 @@ class GelfHandlerLegacyTest extends TestCase
if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) {
$this->markTestSkipped("mlehner/gelf-php not installed");
}
require_once __DIR__ . '/GelfMocks.php';
}
/**

View File

@@ -64,7 +64,6 @@ class GelfHandlerTest extends TestCase
$handler = $this->getHandler($messagePublisher);
$handler->handle($record);
}
@@ -87,7 +86,6 @@ class GelfHandlerTest extends TestCase
$handler = $this->getHandler($messagePublisher);
$handler->handle($record);
}

View File

@@ -1,25 +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;
use Gelf\MessagePublisher;
use Gelf\Message;
class MockMessagePublisher extends MessagePublisher
{
public function publish(Message $message)
{
$this->lastMessage = $message;
}
public $lastMessage = null;
}

View File

@@ -14,7 +14,6 @@ namespace Monolog\Handler;
use Monolog\TestCase;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\RavenHandler;
class RavenHandlerTest extends TestCase
{
@@ -99,7 +98,7 @@ class RavenHandlerTest extends TestCase
$logFormatter->expects($this->once())->method('formatBatch');
$formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
$formatter->expects($this->once())->method('format')->with($this->callback(function($record) {
$formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
return $record['level'] == 400;
}));

View File

@@ -120,7 +120,7 @@ class SocketHandlerTest extends TestCase
{
$this->setMockHandler(array('fwrite'));
$callback = function($arg) {
$callback = function ($arg) {
$map = array(
'Hello world' => 6,
'world' => false,
@@ -143,7 +143,7 @@ class SocketHandlerTest extends TestCase
{
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
$callback = function($arg) {
$callback = function ($arg) {
$map = array(
'Hello world' => 6,
'world' => 5,
@@ -170,7 +170,7 @@ class SocketHandlerTest extends TestCase
$this->setMockHandler(array('fwrite', 'streamGetMetadata'));
$res = $this->res;
$callback = function($string) use ($res) {
$callback = function ($string) use ($res) {
fclose($res);
return strlen('Hello');
@@ -200,7 +200,7 @@ class SocketHandlerTest extends TestCase
{
$this->setMockHandler(array('fwrite'));
$callback = function($arg) {
$callback = function ($arg) {
$map = array(
'Hello world' => 6,
'world' => 5,

View File

@@ -2,8 +2,6 @@
namespace Monolog\Handler;
use Monolog\TestCase;
class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase
{
/**