Skip to content

Commit d1d9bfe

Browse files
committed
Merge branch 'develop' of github.com:OxCom/symfony3-rollbar-bundle into develop
2 parents 8a5eec8 + 558257a commit d1d9bfe

File tree

4 files changed

+68
-15
lines changed

4 files changed

+68
-15
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ script:
1616

1717
after_success:
1818
- bash <(curl -s https://codecov.io/bash)
19+
20+
env:
21+
global:
22+
- secure: "r/35/U9I23Pt54pHDtGIluF4m+YFoRBcEi8vf0DqcZ+qMybThafvb1US5DTfvmIwnWkolc9sOdAZeAapM+0Q2SXJPIwS/JQMxHfvP6nqtZJxdLndYA6aBOJWcHWO5fL47UNMhfXrDtoqLYBkUS+VgqSTNktK/0z5Wm4P/dvMJBPBLb1waNiWC88MLmMzxU64iS7ypzCaw5Qa/vZ7JpmBVuC1aa++1+nJWc0FhT/ptSIggeBRtwyANpvIJifYNfU408eHRTJLBK3LrrgJeyc2U54JwSNQvtBcSPpb7aGNoBfzwpaRd8QoVuzL/LY1XRmedGRprVeY4eAiiHlZQLnR6KIiJFIuxN4Fpw3Vy9WddqjPmFM7JkG5iYu2iXjFVSAWO4gE2P9urZRTd+nsgBkV1Dv3cFEGftXmH+oH3tPzzmInzmlaNiHhs8MSiDvZv1oGPWdtWRAZVzJBxcofoM2GvDxj3NNQAAKWgHsbTb4eXZ3MMwdPbuYdJw/kT9uSPyqbK6zK1IzhrMZglBKZRDmlKelATRly6z2N8JNe0N5vckUYTLba9WcIt1BcaKYH5nIrNJJaYDqhBlSGaAsmwQhPsZN4AFRJzBHI+Bwc8DtxBLyQZC5wd6lL1G/fjHWQbYul6GPghTUR+W6ag/R17BiFjB+K5p1bK/vG9AWdeJjJDOE="

src/Provider/RollbarHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RollbarHandler extends AbstractProcessingHandler
2525
* Records whether any log records have been added since the last flush of the rollbar notifier
2626
* @var bool
2727
*/
28-
private $hasRecords = false;
28+
protected $hasRecords = false;
2929

3030
/**
3131
* Monolog vs Rollbar
@@ -61,7 +61,7 @@ public function __construct(ContainerInterface $container, $level = Logger::ERRO
6161
$rConfig = $config['rollbar'];
6262
$override = [
6363
'root' => $kernel->getRootDir(),
64-
'framework' => \Symfony\Component\HttpKernel\Kernel::VERSION,
64+
'framework' => 'Symfony ' . \Symfony\Component\HttpKernel\Kernel::VERSION,
6565
];
6666

6767
foreach ($override as $key => $value) {

tests/SymfonyRollbarBundle/EventListener/ExceptionListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testInvalidHandleParams($data)
6161
$container = static::$kernel->getContainer();
6262

6363
$handler = new ErrorHandler();
64-
$handler->setAssert(function($record) {
64+
$handler->setAssert(function ($record) {
6565
$this->assertNotEmpty($record);
6666

6767
$this->assertEquals('Undefined exception', $record['message']);
Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
2+
23
namespace Tests\SymfonyRollbarBundle\Provider;
34

5+
use Rollbar\Payload\Level;
46
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
7+
use Symfony\Component\Validator\Constraints\DateTime;
58

69
/**
710
* Class RollbarHandlerTest
11+
*
812
* @package Tests\SymfonyRollbarBundle\Provider
913
*/
1014
class RollbarHandlerTest extends KernelTestCase
@@ -19,7 +23,7 @@ public function setUp()
1923
public function testRollbarHandler()
2024
{
2125
$container = static::$kernel->getContainer();
22-
$handler = new \SymfonyRollbarBundle\Provider\RollbarHandler($container);
26+
$handler = new \SymfonyRollbarBundle\Provider\RollbarHandler($container);
2327

2428
$hContainer = $handler->getContainer();
2529
$this->assertEquals($container, $hContainer);
@@ -28,33 +32,78 @@ public function testRollbarHandler()
2832

2933
/**
3034
* @dataProvider recordGenerator
35+
*
3136
* @param $record
3237
*/
3338
public function testWrite($record)
3439
{
35-
$this->markTestIncomplete('TODO: write body');
40+
$container = static::$kernel->getContainer();
41+
$handler = new \SymfonyRollbarBundle\Provider\RollbarHandler($container);
42+
43+
$property = new \ReflectionProperty($handler, 'hasRecords');
44+
$property->setAccessible(true);
45+
46+
$method = new \ReflectionMethod($handler, 'write');
47+
$method->setAccessible(true);
48+
49+
$this->assertFalse($property->getValue($handler));
50+
$method->invoke($handler, $record);
51+
$this->assertTrue($property->getValue($handler));
3652
}
3753

54+
/**
55+
* @return array
56+
*/
3857
public function recordGenerator()
3958
{
4059
return [
4160
[
4261
[
43-
'context' => [
44-
'level' => \Monolog\Logger::ERROR,
62+
'message' => 'RecordGenerator :: #1',
63+
'datetime' => new \DateTime(),
64+
'level' => \Monolog\Logger::ERROR,
65+
'level_name' => \Monolog\Logger::ERROR,
66+
'channel' => 'symfony.rollbar',
67+
'extra' => [],
68+
'context' => [
4569
'exception' => new \Exception('RecordGenerator :: #1'),
46-
'message' => 'RecordGenerator :: #1',
47-
]
48-
]
70+
],
71+
],
4972
],
5073
[
5174
[
52-
'context' => [
53-
'level' => \Monolog\Logger::ERROR,
54-
'message' => 'RecordGenerator :: #2',
55-
]
56-
]
75+
'message' => 'RecordGenerator :: #2',
76+
'datetime' => new \DateTime(),
77+
'level' => \Monolog\Logger::ERROR,
78+
'level_name' => \Monolog\Logger::ERROR,
79+
'channel' => 'symfony.rollbar',
80+
'extra' => [],
81+
'context' => [],
82+
],
5783
],
5884
];
5985
}
86+
87+
/**
88+
* @dataProvider recordGenerator
89+
* @param $record
90+
*/
91+
public function testClose($record)
92+
{
93+
$container = static::$kernel->getContainer();
94+
$handler = new \SymfonyRollbarBundle\Provider\RollbarHandler($container);
95+
96+
$property = new \ReflectionProperty($handler, 'hasRecords');
97+
$property->setAccessible(true);
98+
99+
$method = new \ReflectionMethod($handler, 'write');
100+
$method->setAccessible(true);
101+
102+
$this->assertFalse($property->getValue($handler));
103+
$method->invoke($handler, $record);
104+
$this->assertTrue($property->getValue($handler));
105+
106+
$handler->close();
107+
$this->assertFalse($property->getValue($handler));
108+
}
60109
}

0 commit comments

Comments
 (0)