mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-30 09:50:26 +02:00
Refactor GelfMessageFormatterTest and GelfHandlerTest so that they don't
fatal error when mlehner/gelf-php is not installed. Fixes GH-78.
This commit is contained in:
@@ -12,9 +12,17 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\GelfMessageFormatter;
|
||||
|
||||
class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists("Gelf\Message")) {
|
||||
$this->markTestSkipped("mlehner/gelf-php not installed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Formatter\GelfMessageFormatter::format
|
||||
*/
|
||||
|
@@ -14,25 +14,16 @@ namespace Monolog\Handler;
|
||||
use Monolog\TestCase;
|
||||
use Monolog\Logger;
|
||||
use Monolog\Formatter\GelfMessageFormatter;
|
||||
use Gelf\MessagePublisher;
|
||||
use Gelf\Message;
|
||||
|
||||
class MockMessagePublisher extends MessagePublisher
|
||||
{
|
||||
public function publish(Message $message) {
|
||||
$this->lastMessage = $message;
|
||||
}
|
||||
|
||||
public $lastMessage = null;
|
||||
}
|
||||
|
||||
class GelfHandlerTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
if (!class_exists("Gelf\MessagePublisher")) {
|
||||
if (!class_exists("Gelf\MessagePublisher") || !class_exists("Gelf\Message")) {
|
||||
$this->markTestSkipped("mlehner/gelf-php not installed");
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/GelfMocks.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
26
tests/Monolog/Handler/GelfMocks.php
Normal file
26
tests/Monolog/Handler/GelfMocks.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user