From b2174a544599eb781374eed595fb41cf133c949d Mon Sep 17 00:00:00 2001 From: oxcom Date: Tue, 28 May 2019 11:10:33 +0200 Subject: [PATCH 1/2] add/delete rollbar configuration options; fix deprecations for sf 4.2+ --- Command/AbstractCommand.php | 35 --------------- Command/DeployCommand.php | 44 +++++++++++++++++-- DependencyInjection/Configuration.php | 11 +++-- Provider/RollbarHandler.php | 9 +++- Resources/config/services.yml | 1 + Resources/doc/configuration.rst | 3 -- Tests/Fixtures/app/AppKernel.php | 11 ++++- Tests/Fixtures/app/config/config_test.yml | 1 + Tests/Fixtures/app/config/config_test_drb.yml | 1 + .../Fixtures/app/config/config_test_drbj.yml | 1 + Tests/Fixtures/app/config/config_test_if.yml | 1 + Tests/Fixtures/app/config/config_test_ifc.yml | 1 + Tests/Fixtures/app/config/config_test_is.yml | 1 + Tests/Fixtures/app/config/config_test_p.yml | 1 + Tests/Fixtures/app/config/config_test_pc.yml | 1 + .../Command/DeployCommandTest.php | 8 ++-- .../DependencyInjection/ConfigurationTest.php | 39 +++++++++++----- .../SymfonyRollbarExtensionTest.php | 8 ++-- .../EventListener/ConsoleListenerTest.php | 10 +++-- .../Provider/CheckIgnoreTest.php | 20 +++++---- .../Provider/RollbarHandlerTest.php | 32 +++++++------- composer.json | 2 +- phpunit.xml.dist | 3 +- 23 files changed, 149 insertions(+), 95 deletions(-) delete mode 100755 Command/AbstractCommand.php diff --git a/Command/AbstractCommand.php b/Command/AbstractCommand.php deleted file mode 100755 index f433cba..0000000 --- a/Command/AbstractCommand.php +++ /dev/null @@ -1,35 +0,0 @@ -io = $io; - } -} diff --git a/Command/DeployCommand.php b/Command/DeployCommand.php index 192112e..401c624 100644 --- a/Command/DeployCommand.php +++ b/Command/DeployCommand.php @@ -2,20 +2,58 @@ namespace SymfonyRollbarBundle\Command; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class DeployCommand * * @package SymfonyRollbarBundle\Command */ -class DeployCommand extends \SymfonyRollbarBundle\Command\AbstractCommand +class DeployCommand extends Command { protected static $defaultName = 'rollbar:deploy'; + /** + * @var \Symfony\Component\Console\Style\SymfonyStyle + */ + protected $io; + + /** + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + + /** + * DeployCommand constructor. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + */ + public function __construct(ContainerInterface $container) + { + parent::__construct(); + + $this->container = $container; + } + + /** + * Extend the initialize method to add additional parameters to the class. + * + * {@inheritdoc} + */ + public function initialize(InputInterface $input, OutputInterface $output) + { + parent::initialize($input, $output); + + $io = new SymfonyStyle($input, $output); + $this->io = $io; + } + /** * @inheritdoc */ @@ -65,9 +103,9 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { /** @var \SymfonyRollbarBundle\Provider\RollbarHandler $rbHandler */ - $rbHandler = $this->getContainer()->get('symfony_rollbar.provider.rollbar_handler'); + $rbHandler = $this->container->get('symfony_rollbar.provider.rollbar_handler'); - $environment = $this->getContainer()->getParameter('kernel.environment'); + $environment = $this->container->getParameter('kernel.environment'); $revision = $input->getArgument('revision'); $comment = $input->getOption('comment'); $rUser = $input->getOption('rollbar_username'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 35c064f..a2002ba 100755 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -26,6 +26,9 @@ class Configuration implements ConfigurationInterface const API_ENDPOINT = 'https://api.rollbar.com/api/1/'; const PHP_MAX_ITEMS = 10; + const MIN_OCCURRENCES_LEVEL = 0; + + const VERBOSE = 'none'; const JS_ITEMS_PER_MINUTE = 60; const JS_MAX_ITEMS = 0; @@ -98,7 +101,6 @@ public function getConfigTreeBuilder() ->booleanNode('capture_error_stacktraces')->defaultTrue()->end() ->scalarNode('check_ignore')->defaultNull()->end() ->scalarNode('code_version')->defaultValue('')->end() - ->booleanNode('enable_utf8_sanitization')->defaultTrue()->end() ->scalarNode('environment')->defaultValue(static::ENVIRONMENT)->end() ->arrayNode('custom') ->treatNullLike([]) @@ -159,8 +161,6 @@ public function getConfigTreeBuilder() ->end() ->scalarNode('scrub_whitelist')->defaultNull()->end() ->scalarNode('transformer')->defaultNull()->end() - ->scalarNode('verbosity')->defaultValue(\Psr\Log\LogLevel::ERROR)->end() - ->booleanNode('shift_function')->defaultTrue()->end() ->scalarNode('timeout')->defaultValue(static::TIMEOUT)->end() ->booleanNode('report_suppressed')->defaultFalse()->end() ->booleanNode('use_error_reporting')->defaultFalse()->end() @@ -170,6 +170,11 @@ public function getConfigTreeBuilder() ->booleanNode('local_vars_dump')->defaultTrue()->end() ->scalarNode('max_nesting_depth')->defaultValue(-1)->end() ->scalarNode('max_items')->defaultValue(static::PHP_MAX_ITEMS)->end() + ->booleanNode('log_payload')->defaultFalse()->end() + ->booleanNode('raise_on_error')->defaultFalse()->end() + ->booleanNode('transmit')->defaultTrue()->end() + ->scalarNode('verbose')->defaultValue(static::VERBOSE)->end() + ->scalarNode('minimum_level')->defaultValue(static::MIN_OCCURRENCES_LEVEL)->end() ->end() ->end() ->arrayNode('rollbar_js')->children() diff --git a/Provider/RollbarHandler.php b/Provider/RollbarHandler.php index bd9ceb8..62154d9 100755 --- a/Provider/RollbarHandler.php +++ b/Provider/RollbarHandler.php @@ -6,6 +6,7 @@ use Monolog\Logger; use Rollbar\Rollbar as RollbarNotifier; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpKernel\Kernel; use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension; use Rollbar\Payload\Level; use SymfonyRollbarBundle\Provider\Api\Filter; @@ -121,9 +122,13 @@ protected function initialize() $rConfig = $config['rollbar']; // override specific values + $root = \method_exists($kernel, 'getProjectDir') + ? $kernel->getProjectDir() + : $kernel->getRootDir(); + $override = [ - 'root' => $kernel->getRootDir(), - 'framework' => 'Symfony ' . \Symfony\Component\HttpKernel\Kernel::VERSION, + 'root' => $root, + 'framework' => 'Symfony ' . Kernel::VERSION, ]; foreach ($override as $key => $value) { diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 29f8f8f..15f9519 100755 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -33,6 +33,7 @@ services: symfony_rollbar.command.deploy: class: "%symfony_rollbar.command.deploy.class%" + arguments: ["@service_container"] tags: - {name: console.command, command: "rollbar:deploy"} diff --git a/Resources/doc/configuration.rst b/Resources/doc/configuration.rst index 1002c4c..7e8435d 100755 --- a/Resources/doc/configuration.rst +++ b/Resources/doc/configuration.rst @@ -19,7 +19,6 @@ Simple configuration of bundle: capture_error_stacktraces: true check_ignore: null code_version: '' - enable_utf8_sanitization': true environment: 'production' custom: - {key: hello, value: world} @@ -47,7 +46,6 @@ Simple configuration of bundle: root: '%kernel.root_dir%' scrub_fields: ['passwd', 'password', 'secret', 'confirm_password', 'password_confirmation', 'auth_token', 'csrf_token'] scrub_whitelist: null - shift_function': true timeout: 3 report_suppressed: false use_error_reporting: false @@ -62,7 +60,6 @@ Simple configuration of bundle: custom_truncation: null ca_cert_path: null transformer: null - verbosity: 'error' rollbar_js: enabled: true access_token: 'some-public-token' diff --git a/Tests/Fixtures/app/AppKernel.php b/Tests/Fixtures/app/AppKernel.php index 1e8a9f7..bcc76da 100755 --- a/Tests/Fixtures/app/AppKernel.php +++ b/Tests/Fixtures/app/AppKernel.php @@ -1,15 +1,17 @@ getRootDir(); + } + /** * @param \Symfony\Component\Config\Loader\LoaderInterface $loader * diff --git a/Tests/Fixtures/app/config/config_test.yml b/Tests/Fixtures/app/config/config_test.yml index 443e277..607e7c8 100755 --- a/Tests/Fixtures/app/config/config_test.yml +++ b/Tests/Fixtures/app/config/config_test.yml @@ -10,6 +10,7 @@ symfony_rollbar: - \ParseError - \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person_fn: \SymfonyRollbarBundle\Tests\Fixtures\PersonProvider diff --git a/Tests/Fixtures/app/config/config_test_drb.yml b/Tests/Fixtures/app/config/config_test_drb.yml index 0f35ace..d6aa758 100755 --- a/Tests/Fixtures/app/config/config_test_drb.yml +++ b/Tests/Fixtures/app/config/config_test_drb.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' diff --git a/Tests/Fixtures/app/config/config_test_drbj.yml b/Tests/Fixtures/app/config/config_test_drbj.yml index 47f2ee6..cd1a673 100755 --- a/Tests/Fixtures/app/config/config_test_drbj.yml +++ b/Tests/Fixtures/app/config/config_test_drbj.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' diff --git a/Tests/Fixtures/app/config/config_test_if.yml b/Tests/Fixtures/app/config/config_test_if.yml index 4eb1cd2..2003ae9 100755 --- a/Tests/Fixtures/app/config/config_test_if.yml +++ b/Tests/Fixtures/app/config/config_test_if.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person_fn: "get_awesome_person" diff --git a/Tests/Fixtures/app/config/config_test_ifc.yml b/Tests/Fixtures/app/config/config_test_ifc.yml index 19f159e..a4824c4 100755 --- a/Tests/Fixtures/app/config/config_test_ifc.yml +++ b/Tests/Fixtures/app/config/config_test_ifc.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person_fn: "get_awesome_person" diff --git a/Tests/Fixtures/app/config/config_test_is.yml b/Tests/Fixtures/app/config/config_test_is.yml index e5780cb..c3038ab 100755 --- a/Tests/Fixtures/app/config/config_test_is.yml +++ b/Tests/Fixtures/app/config/config_test_is.yml @@ -10,6 +10,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person_fn: "symfony_rollbar.fixture.person_provider" diff --git a/Tests/Fixtures/app/config/config_test_p.yml b/Tests/Fixtures/app/config/config_test_p.yml index 98e7094..56255a4 100644 --- a/Tests/Fixtures/app/config/config_test_p.yml +++ b/Tests/Fixtures/app/config/config_test_p.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person: diff --git a/Tests/Fixtures/app/config/config_test_pc.yml b/Tests/Fixtures/app/config/config_test_pc.yml index 8a83232..ea3e7a5 100644 --- a/Tests/Fixtures/app/config/config_test_pc.yml +++ b/Tests/Fixtures/app/config/config_test_pc.yml @@ -9,6 +9,7 @@ symfony_rollbar: - \SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException - \ParseError rollbar: + transmit: false access_token: 'SOME_ROLLBAR_ACCESS_TOKEN_123456' environment: '%kernel.environment%' person: diff --git a/Tests/SymfonyRollbarBundle/Command/DeployCommandTest.php b/Tests/SymfonyRollbarBundle/Command/DeployCommandTest.php index 098c5ae..b012dde 100644 --- a/Tests/SymfonyRollbarBundle/Command/DeployCommandTest.php +++ b/Tests/SymfonyRollbarBundle/Command/DeployCommandTest.php @@ -21,8 +21,9 @@ public function setUp() public function testRegistration() { + $container = static::$kernel->getContainer(); $application = new Application(static::$kernel); - $application->add(new DeployCommand()); + $application->add(new DeployCommand($container)); try { $application->find('rollbar:deploy'); @@ -71,7 +72,7 @@ public function testExecute($input, $expected, $message) $container->set('symfony_rollbar.provider.api_client', $client); $application = new Application(static::$kernel); - $application->add(new DeployCommand()); + $application->add(new DeployCommand($container)); try { $command = $application->find('rollbar:deploy'); @@ -112,8 +113,9 @@ public function generateExecuteInput() public function testExecuteGeneric() { + $container = static::$kernel->getContainer(); $application = new Application(static::$kernel); - $application->add(new DeployCommand()); + $application->add(new DeployCommand($container)); $command = $application->find('rollbar:deploy'); $commandTester = new CommandTester($command); diff --git a/Tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php b/Tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php index 8fac3af..8ea715e 100755 --- a/Tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php +++ b/Tests/SymfonyRollbarBundle/DependencyInjection/ConfigurationTest.php @@ -46,6 +46,10 @@ public function testParameters() 'key' => 'value', ]; + $root = \method_exists(static::$kernel, 'getProjectDir') + ? static::$kernel->getProjectDir() + : static::$kernel->getRootDir(); + $default = [ 'enable' => true, 'exclude' => $exclude, @@ -58,7 +62,6 @@ public function testParameters() 'capture_error_stacktraces' => true, 'check_ignore' => '\SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider', 'code_version' => '', - 'enable_utf8_sanitization' => true, 'environment' => static::$kernel->getEnvironment(), 'error_sample_rates' => $errorRates, 'handler' => Configuration::HANDLER_BLOCKING, @@ -68,9 +71,8 @@ public function testParameters() 'logger' => null, 'person' => [], 'person_fn' => '\SymfonyRollbarBundle\Tests\Fixtures\PersonProvider', - 'root' => static::$kernel->getRootDir(), + 'root' => $root, 'scrub_fields' => Configuration::$scrubFieldsDefault, - 'shift_function' => true, 'timeout' => 3, 'report_suppressed' => false, 'use_error_reporting' => false, @@ -94,9 +96,13 @@ public function testParameters() 'custom_truncation' => null, 'ca_cert_path' => null, 'transformer' => null, - 'verbosity' => 'error', 'max_nesting_depth' => -1, + 'transmit' => false, 'max_items' => Configuration::PHP_MAX_ITEMS, + 'log_payload' => false, + 'minimum_level' => Configuration::MIN_OCCURRENCES_LEVEL, + 'raise_on_error' => false, + 'verbose' => Configuration::VERBOSE, ], 'rollbar_js' => [ 'access_token' => 'SOME_ROLLBAR_ACCESS_TOKEN_654321', @@ -136,15 +142,24 @@ public function testCompareRollbarDefaults() static::bootKernel(); $container = static::$kernel->getContainer(); - $config = $container->getParameter(SymfonyRollbarExtension::ALIAS . '.config'); - $rbConfig = Config::listOptions(); + $config = $container->getParameter(SymfonyRollbarExtension::ALIAS . '.config'); + $rbConfig = Config::listOptions(); + $bundleConfig = \array_keys($config['rollbar']); + + // add options that are not in list of options for rollbar native config, but they are in use + $rbConfig[] = 'ca_cert_path'; + $rbConfig[] = 'logger'; + $rbConfig[] = 'transformer'; + + // bundle config does not handle 'enabled' config property + $bundleConfig[] = 'enabled'; + // @TODO: add support of next config property + $bundleConfig[] = 'log_payload_logger'; + $bundleConfig[] = 'verbose_logger'; - foreach ($rbConfig as $key) { - if ($key === 'enabled') { - continue; - } + asort($rbConfig); + asort($bundleConfig); - $this->assertArrayHasKey($key, $config['rollbar']); - } + $this->assertEquals(\array_values($rbConfig), \array_values($bundleConfig)); } } diff --git a/Tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php b/Tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php index b2602e1..2e83120 100755 --- a/Tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php +++ b/Tests/SymfonyRollbarBundle/DependencyInjection/SymfonyRollbarExtensionTest.php @@ -56,7 +56,6 @@ public function generatorConfigVars() 'capture_error_stacktraces' => true, 'check_ignore' => null, 'code_version' => '', - 'enable_utf8_sanitization' => true, 'environment' => Configuration::ENVIRONMENT, 'error_sample_rates' => [], 'handler' => Configuration::HANDLER_BLOCKING, @@ -68,7 +67,6 @@ public function generatorConfigVars() 'person_fn' => null, 'root' => '%kernel.root_dir%', 'scrub_fields' => Configuration::$scrubFieldsDefault, - 'shift_function' => true, 'timeout' => 3, 'report_suppressed' => false, 'use_error_reporting' => false, @@ -92,9 +90,13 @@ public function generatorConfigVars() 'custom_truncation' => null, 'ca_cert_path' => null, 'transformer' => null, - 'verbosity' => 'error', 'max_nesting_depth' => -1, 'max_items' => Configuration::PHP_MAX_ITEMS, + 'log_payload' => false, + 'minimum_level' => Configuration::MIN_OCCURRENCES_LEVEL, + 'raise_on_error' => false, + 'verbose' => Configuration::VERBOSE, + 'transmit' => true, ], ]; diff --git a/Tests/SymfonyRollbarBundle/EventListener/ConsoleListenerTest.php b/Tests/SymfonyRollbarBundle/EventListener/ConsoleListenerTest.php index 9db07e5..2b556ff 100755 --- a/Tests/SymfonyRollbarBundle/EventListener/ConsoleListenerTest.php +++ b/Tests/SymfonyRollbarBundle/EventListener/ConsoleListenerTest.php @@ -31,7 +31,7 @@ public function setUp() /** * @dataProvider provideLegacyEvents - * @covers \SymfonyRollbarBundle\EventListener\ExceptionListener::onConsoleError + * @covers \SymfonyRollbarBundle\EventListener\ExceptionListener::onConsoleError * * @param $error * @param $event @@ -93,15 +93,17 @@ public function testLegacyConsoleException($error, $event) */ public function provideLegacyEvents() { - $input = new ArrayInput([]); + $input = new ArrayInput([]); $output = new StreamOutput( fopen('php://memory', 'w', false), OutputInterface::VERBOSITY_QUIET, false ); - $error = new \Exception('This is console exception'); - $command = new DeployCommand(); + static::bootKernel(); + $container = static::$kernel->getContainer(); + $error = new \Exception('This is console exception'); + $command = new DeployCommand($container); $events = []; diff --git a/Tests/SymfonyRollbarBundle/Provider/CheckIgnoreTest.php b/Tests/SymfonyRollbarBundle/Provider/CheckIgnoreTest.php index aea4afc..64b209a 100644 --- a/Tests/SymfonyRollbarBundle/Provider/CheckIgnoreTest.php +++ b/Tests/SymfonyRollbarBundle/Provider/CheckIgnoreTest.php @@ -2,6 +2,10 @@ namespace SymfonyRollbarBundle\Tests\Provider; +use Rollbar\Payload\Body; +use Rollbar\Payload\Data; +use Rollbar\Payload\Message; +use Rollbar\Payload\Payload; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use SymfonyRollbarBundle\Provider\RollbarHandler; use SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider; @@ -45,10 +49,10 @@ public function testCheckIgnore($env, $expected) $service->setIgnore($expected); - $message = new \Rollbar\Payload\Message('rollbar'); - $body = new \Rollbar\Payload\Body($message); - $data = new \Rollbar\Payload\Data($env, $body); - $payload = new \Rollbar\Payload\Payload($data, $config['access_token']); + $message = new Message('rollbar'); + $body = new Body($message); + $data = new Data($env, $body); + $payload = new Payload($data, $config['access_token']); $ignore = call_user_func($call, false, 'toLog', $payload); @@ -90,10 +94,10 @@ public function testPersonProviderFunction() $method = $config['check_ignore']; $this->assertEquals('should_ignore', $method); - $message = new \Rollbar\Payload\Message('rollbar'); - $body = new \Rollbar\Payload\Body($message); - $data = new \Rollbar\Payload\Data($env, $body); - $payload = new \Rollbar\Payload\Payload($data, $config['access_token']); + $message = new Message('rollbar'); + $body = new Body($message); + $data = new Data($env, $body); + $payload = new Payload($data, $config['access_token']); $ignore = call_user_func($method, false, 'toLog', $payload); $this->assertFalse($ignore); diff --git a/Tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php b/Tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php index 524d1a5..1b7d30e 100755 --- a/Tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php +++ b/Tests/SymfonyRollbarBundle/Provider/RollbarHandlerTest.php @@ -6,7 +6,9 @@ use SymfonyRollbarBundle\DependencyInjection\Configuration; use SymfonyRollbarBundle\Provider\RollbarHandler; use SymfonyRollbarBundle\Tests\Fixtures\ApiClientMock; +use SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider; use SymfonyRollbarBundle\Tests\Fixtures\MyAwesomeException; +use SymfonyRollbarBundle\Tests\Fixtures\PersonProvider; /** * Class RollbarHandlerTest @@ -119,7 +121,7 @@ public function recordGenerator() 'channel' => 'symfony.rollbar', 'extra' => [], 'context' => [ - 'payload' => [1, 2, 3] + 'payload' => [1, 2, 3], ], ], ], @@ -128,6 +130,7 @@ public function recordGenerator() /** * @dataProvider recordGenerator + * * @param $record */ public function testClose($record) @@ -192,7 +195,7 @@ public function testContextPayload() 'extra' => [], 'context' => [ 'exception' => new MyAwesomeException('RecordGenerator :: #4'), - 'payload' => [4, 5, 6] + 'payload' => [4, 5, 6], ], ]; @@ -315,6 +318,10 @@ public function testInitialize() 'key' => 'value', ]; + $root = \method_exists(static::$kernel, 'getProjectDir') + ? static::$kernel->getProjectDir() + : static::$kernel->getRootDir(); + $default = [ 'access_token' => 'SOME_ROLLBAR_ACCESS_TOKEN_123456', 'agent_log_location' => static::$kernel->getLogDir() . '/rollbar.log', @@ -322,12 +329,8 @@ public function testInitialize() 'branch' => Configuration::BRANCH, 'autodetect_branch' => false, 'capture_error_stacktraces' => true, - 'check_ignore' => [ - new \SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider(), - 'checkIgnore', - ], + 'check_ignore' => [new CheckIgnoreProvider(), 'checkIgnore'], 'code_version' => '', - 'enable_utf8_sanitization' => true, 'environment' => static::$kernel->getEnvironment(), 'error_sample_rates' => $errorRates, 'handler' => Configuration::HANDLER_BLOCKING, @@ -336,13 +339,9 @@ public function testInitialize() 'included_errno' => $defaultErrorMask, 'logger' => null, 'person' => null, - 'person_fn' => [ - new \SymfonyRollbarBundle\Tests\Fixtures\PersonProvider($container), - 'getPerson', - ], - 'root' => static::$kernel->getRootDir(), + 'person_fn' => [new PersonProvider($container), 'getPerson'], + 'root' => $root, 'scrub_fields' => Configuration::$scrubFieldsDefault, - 'shift_function' => true, 'timeout' => 3, 'report_suppressed' => false, 'use_error_reporting' => false, @@ -366,11 +365,14 @@ public function testInitialize() 'custom_truncation' => null, 'ca_cert_path' => null, 'transformer' => null, - 'verbosity' => 'error', 'framework' => 'Symfony ' . \Symfony\Component\HttpKernel\Kernel::VERSION, 'max_nesting_depth' => -1, 'max_items' => Configuration::PHP_MAX_ITEMS, - + 'log_payload' => false, + 'raise_on_error' => false, + 'transmit' => false, + 'verbose' => Configuration::VERBOSE, + 'minimum_level' => Configuration::MIN_OCCURRENCES_LEVEL, ]; $this->assertEquals($default, $config); diff --git a/composer.json b/composer.json index a13309c..50fc666 100755 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require": { "php": ">=5.6", "monolog/monolog": "^1.23", - "rollbar/rollbar": "^1.6", + "rollbar/rollbar": "^1.8", "symfony/dependency-injection": "^2.8|~3.0|~4.0|~4.1|~4.2", "symfony/config": "^2.8|~3.0|~4.0|~4.1|~4.2", "symfony/http-kernel": "^2.8|~3.0|~4.0|~4.1|~4.2", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index af1749e..8a5a658 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,6 +8,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" + convertDeprecationsToExceptions="true" bootstrap="./Tests/Fixtures/app/autoload.php" > @@ -17,7 +18,7 @@ - + From a39a4686002711cb6759e7a0067f406a40628382 Mon Sep 17 00:00:00 2001 From: oxcom Date: Tue, 28 May 2019 11:20:35 +0200 Subject: [PATCH 2/2] return back phpunit config --- Tests/SymfonyRollbarBundle/Twig/RollbarExtensionTest.php | 3 ++- Twig/RollbarExtension.php | 6 ++++-- phpunit.xml.dist | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Tests/SymfonyRollbarBundle/Twig/RollbarExtensionTest.php b/Tests/SymfonyRollbarBundle/Twig/RollbarExtensionTest.php index 9797fd7..0e632d5 100755 --- a/Tests/SymfonyRollbarBundle/Twig/RollbarExtensionTest.php +++ b/Tests/SymfonyRollbarBundle/Twig/RollbarExtensionTest.php @@ -5,6 +5,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use SymfonyRollbarBundle\DependencyInjection\Configuration; use SymfonyRollbarBundle\Twig\RollbarExtension; +use Twig\TwigFunction; /** * Class RollbarExtensionTest @@ -42,7 +43,7 @@ public function testRollbarJs($env, $isDisabled) $this->assertNotEmpty($list); $function = $list[0]; - $this->assertInstanceOf(\Twig\TwigFunction::class, $function); + $this->assertInstanceOf(TwigFunction::class, $function); $output = $rollbarTwig->rollbarJs(); diff --git a/Twig/RollbarExtension.php b/Twig/RollbarExtension.php index f44984f..bbd842f 100755 --- a/Twig/RollbarExtension.php +++ b/Twig/RollbarExtension.php @@ -5,8 +5,10 @@ use Rollbar\RollbarJsHelper; use Symfony\Component\DependencyInjection\ContainerInterface; use SymfonyRollbarBundle\DependencyInjection\SymfonyRollbarExtension; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; -class RollbarExtension extends \Twig\Extension\AbstractExtension +class RollbarExtension extends AbstractExtension { /** * @var \Symfony\Component\DependencyInjection\ContainerInterface @@ -48,7 +50,7 @@ public function getFunctions() } return [ - new \Twig\TwigFunction('rollbarJs', [$this, 'rollbarJs'], [ + new TwigFunction('rollbarJs', [$this, 'rollbarJs'], [ 'is_safe' => ['html'], ]), ]; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8a5a658..af1749e 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - convertDeprecationsToExceptions="true" bootstrap="./Tests/Fixtures/app/autoload.php" > @@ -18,7 +17,7 @@ - +