1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-23 22:42:38 +01:00

Pull MockRavenClient (which depends on Raven_Client) out of

tests/Monolog/Handler/RavenHandlerTest.php into a separate file so that
the test can pass when raven-php is installed and can be skipped when
raven-php is not installed. Addresses @Stof's comment in
https://github.com/Seldaek/monolog/pull/76#r740465
This commit is contained in:
Marc Abramowitz 2012-04-26 15:03:43 -07:00
parent 6b4b2a6ac0
commit 44d2441782
2 changed files with 30 additions and 15 deletions

View 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 Raven_Client;
class MockRavenClient extends Raven_Client
{
public function capture($data, $stack)
{
$this->lastData = $data;
$this->lastStack = $stack;
}
public $lastData;
public $lastStack;
}

View File

@ -14,19 +14,6 @@ namespace Monolog\Handler;
use Monolog\TestCase;
use Monolog\Logger;
use Monolog\Handler\RavenHandler;
use \Raven_Client;
class MockRavenClient extends Raven_Client
{
public function capture($data, $stack)
{
$this->lastData = $data;
$this->lastStack = $stack;
}
public $lastData;
public $lastStack;
}
class RavenHandlerTest extends TestCase
{
@ -35,6 +22,8 @@ class RavenHandlerTest extends TestCase
if (!class_exists("Raven_Client")) {
$this->markTestSkipped("raven/raven not installed");
}
require_once __DIR__ . '/MockRavenClient.php';
}
/**
@ -66,7 +55,7 @@ class RavenHandlerTest extends TestCase
$record = $this->getRecord(Logger::DEBUG, "A test debug message");
$handler->handle($record);
$this->assertEquals(Raven_Client::DEBUG, $ravenClient->lastData['level']);
$this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
$this->assertContains($record['message'], $ravenClient->lastData['message']);
}
@ -78,7 +67,7 @@ class RavenHandlerTest extends TestCase
$record = $this->getRecord(Logger::WARNING, "A test warning message");
$handler->handle($record);
$this->assertEquals(Raven_Client::WARNING, $ravenClient->lastData['level']);
$this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
$this->assertContains($record['message'], $ravenClient->lastData['message']);
}