forked from OxCom/symfony-rollbar-bundle
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathRollbarHandlerFactoryTest.php
executable file
·56 lines (45 loc) · 1.8 KB
/
RollbarHandlerFactoryTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Rollbar\Symfony\RollbarBundle\Tests\Factories;
use Rollbar\Config;
use Rollbar\Defaults;
use Psr\Log\LogLevel;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension;
use Rollbar\Symfony\RollbarBundle\Factories\RollbarHandlerFactory;
use Rollbar\Rollbar;
use Rollbar\Payload\Level;
/**
* Class RollbarHandlerFactoryTest
*
* @package Rollbar\Symfony\RollbarBundle\Tests\Factories;
*/
class RollbarHandlerFactoryTest extends KernelTestCase
{
public static function setUpBeforeClass()
{
self::bootKernel();
}
public function testMinimumLevel()
{
$factory = new RollbarHandlerFactory(self::$container);
$getAccessTokenMethod = new \ReflectionMethod('\Rollbar\RollbarLogger', 'getAccessToken');
$getAccessTokenMethod->setAccessible(true);
$accessToken = $getAccessTokenMethod->invoke(Rollbar::logger());
$mockLogger = $this->getMockBuilder('\Rollbar\RollbarLogger')
->setConstructorArgs(array(array(
'access_token' => $accessToken,
'minimum_level' => LogLevel::ERROR
)))
->getMock();
$rollbarClass = new \ReflectionClass('\Rollbar\Rollbar');
$setLoggerMethod = $rollbarClass->getMethod('setLogger');
$setLoggerMethod->setAccessible(true);
$setLoggerMethod->invoke(null, $mockLogger);
$logger = self::$container->get('test_alias.logger');
$mockLogger->expects($this->once())
->method('log')
->with($this->equalTo(Level::ERROR));
$logger->log(Level::ERROR, "Test info from the factory test");
$logger->log(Level::INFO, "Test debug from the factory test");
}
}