summaryrefslogtreecommitdiff
path: root/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php')
-rw-r--r--vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php45
1 files changed, 40 insertions, 5 deletions
diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
index 8fe86961..9a9d1006 100644
--- a/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
+++ b/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php
@@ -19,8 +19,8 @@ class RavenHandlerTest extends TestCase
{
public function setUp()
{
- if (!class_exists("Raven_Client")) {
- $this->markTestSkipped("raven/raven not installed");
+ if (!class_exists('Raven_Client')) {
+ $this->markTestSkipped('raven/raven not installed');
}
require_once __DIR__ . '/MockRavenClient.php';
@@ -54,7 +54,7 @@ class RavenHandlerTest extends TestCase
$ravenClient = $this->getRavenClient();
$handler = $this->getHandler($ravenClient);
- $record = $this->getRecord(Logger::DEBUG, "A test debug message");
+ $record = $this->getRecord(Logger::DEBUG, 'A test debug message');
$handler->handle($record);
$this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
@@ -66,7 +66,7 @@ class RavenHandlerTest extends TestCase
$ravenClient = $this->getRavenClient();
$handler = $this->getHandler($ravenClient);
- $record = $this->getRecord(Logger::WARNING, "A test warning message");
+ $record = $this->getRecord(Logger::WARNING, 'A test warning message');
$handler->handle($record);
$this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
@@ -79,12 +79,47 @@ class RavenHandlerTest extends TestCase
$handler = $this->getHandler($ravenClient);
$tags = array(1, 2, 'foo');
- $record = $this->getRecord(Logger::INFO, "test", array('tags' => $tags));
+ $record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags));
$handler->handle($record);
$this->assertEquals($tags, $ravenClient->lastData['tags']);
}
+ public function testUserContext()
+ {
+ $ravenClient = $this->getRavenClient();
+ $handler = $this->getHandler($ravenClient);
+
+ $recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
+ // set user context 'externally'
+
+ $user = array(
+ 'id' => '123',
+ 'email' => 'test@test.com'
+ );
+
+ $recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
+
+ $ravenClient->user_context(array('id' => 'test_user_id'));
+ // handle context
+ $handler->handle($recordWithContext);
+ $this->assertEquals($user, $ravenClient->lastData['sentry.interfaces.User']);
+
+ // check to see if its reset
+ $handler->handle($recordWithNoContext);
+ $this->assertInternalType('array', $ravenClient->context->user);
+ $this->assertSame('test_user_id', $ravenClient->context->user['id']);
+
+ // handle with null context
+ $ravenClient->user_context(null);
+ $handler->handle($recordWithContext);
+ $this->assertEquals($user, $ravenClient->lastData['sentry.interfaces.User']);
+
+ // check to see if its reset
+ $handler->handle($recordWithNoContext);
+ $this->assertNull($ravenClient->context->user);
+ }
+
public function testException()
{
$ravenClient = $this->getRavenClient();