Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amended PR: Add listen new config param "minimum_level" error log. #46

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Tests/Factories/RollbarHandlerFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,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");
}
}
5 changes: 5 additions & 0 deletions Tests/Fixtures/app/config/packages/rollbar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rollbar:
enabled: true
access_token: ~ # pulled from phpunit.xml
environment: 'rollbar-php-symfony-test-app'
minimum_level: 'info'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an empty line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the reason this PR was never merged?